public ImageCollection(ThumbsFile root) : base() { this.count = 0; this.root = root; this.paths = new Gen::Dictionary <string, Thumb>(); this.sorted = new afh.Collections.SortedArrayP <Thumb>(); }
/// <summary> /// afh.Collections.SortedArray`2 が正しく動作するかの実験を行います。 /// </summary> public static void dbg_SortedArray1() { //afh.Collections.SortedArray<int,int> s=new afh.Collections.SortedArray<int,int>(); afh.Collections.SortedArrayP <int> s = new afh.Collections.SortedArrayP <int>(); s.Add(342); s.Add(543); s.Add(123); s.Add(123); s.Add(565); s.Add(563); s.Add(112); s.Add(453); s.Add(563); s.Add(345); s.Add(435); s.Add(321); s.Add(312); s.Remove(112); s.Add(142); int i = 0; foreach (int value in s) { System.Console.WriteLine("{0} : {1}", i++, value); } }
/// <summary> /// afh.Collections.SortedArray`2 が正しく動作するかの実験を行います。 /// </summary> public static void dbg_SortedArray2() { //afh.Collections.SortedArray<int,int> s=new afh.Collections.SortedArray<int,int>(); afh.Collections.SortedArrayP <int, int> s = new afh.Collections.SortedArrayP <int, int>(); s.Add(342, 4); s.Add(543, 5); s.Add(123, 78); s.Add(123, 98); s.Add(565, 89); s.Add(563, 312); s.Add(112, 455); s.Add(453, 89); s.Add(563, 34); s.Add(345, 789); s.Add(435, 890); s.Add(321, 3); s.Add(312, 8); foreach (Gen::KeyValuePair <int, int> pair in s) { System.Console.WriteLine("{0} : {1}", pair.Key, pair.Value); } }
private ImageCollection(int capacity) : base(capacity) { this.paths = new Gen::Dictionary <string, Thumb>(capacity); this.sorted = new afh.Collections.SortedArrayP <Thumb>(capacity); }
public static void SearchNearImage(ThumbsFile file) { ImageDirectory overlap = new ImageDirectory("<重複検索>", file); afh.Collections.SortedArrayP <Thumb> images = file.thumbs.SortedThumbs; Gen::Dictionary <Image, ImageDirectory> groups = new Gen::Dictionary <Image, ImageDirectory>(); afh.Forms.ProgressDialog progress = new afh.Forms.ProgressDialog(); progress.Title = "重複比較中 ..."; progress.ProgressMax = images.Count; progress.Show(); for (int i = 0; i < images.Count; i++) { Image img1 = new Image(file, images[i]); if (i % 50 == 0) { progress.Description = "画像 '" + img1.thm.filepath + "' の類似画像を探索中 ..."; if (progress.IsCanceled) { return; } } for (int j = i + 1; j < images.Count; j++) { Image img2 = new Image(file, images[j]); if (!Image.EqualAspect(img1, img2)) { break; } if (Image.Resembles(img1, img2)) { ImageDirectory group1 = null; ImageDirectory group2 = null; bool b1 = groups.TryGetValue(img1, out group1); bool b2 = groups.TryGetValue(img2, out group2); switch ((b1?1:0) | (b2?2:0)) { case 3: // 両方 if (group1 == group2) { break; } // 両グループの併合 overlap.dirs.Remove(group2); foreach (Image img in group2.EnumImages()) { group1.Add(img); groups[img] = group1; } break; case 1: // group1 だけ group1.Add(img2); groups.Add(img2, group1); break; case 2: // group2 だけ group2.Add(img1); groups.Add(img1, group2); break; case 0: // 両者未登録 ImageDirectory group = new ImageDirectory("Group " + overlap.dirs.Count.ToString(), file); group.Add(img1); group.Add(img2); groups.Add(img1, group); groups.Add(img2, group); overlap.Add(group); break; default: throw new System.InvalidProgramException(); } //System.Console.WriteLine("次の画像は似ています\r\n {0}\r\n {1}",thm1.filepath,thm2.filepath); } } if (i % 10 == 0) { progress.Progress = i; } } progress.Close(); file.dirs.Add(overlap); }