Example #1
0
 /// <summary>
 /// 指定したディレクトリをこのディレクトリのサブディレクトリに追加します。
 /// </summary>
 /// <param name="directory">サブディレクトリとして追加するディレクトリを指定します。</param>
 public void Add(ImageDirectory directory)
 {
     if (directory.root != this.root)
     {
         throw new System.NotImplementedException("異なるファイルのディレクトリを追加する操作は未実装です。");
     }
     else
     {
         this.dirs.Add(directory);
     }
 }
Example #2
0
        private static void write(ImageDirectory dir, StreamAccessor accessor)
        {
            accessor.Write(dir.name, EncodingType.NoSpecified);

            accessor.Write((uint)dir.images.Count, EncodingType.U4);
            foreach (int index in dir.images)
            {
                accessor.Write(index, EncodingType.I4);
            }

            accessor.Write(dir.dirs);
        }
Example #3
0
        private static ImageDirectory read(StreamAccessor accessor)
        {
            ImageDirectory dir = new ImageDirectory(accessor.ReadString(EncodingType.NoSpecified));

            uint count = accessor.ReadUInt32(EncodingType.U4);

            for (int i = 0; i < count; i++)
            {
                dir.images.Add(accessor.ReadInt32(EncodingType.I4));
            }

            dir.dirs = accessor.Read <DirectoryCollection>();
            return(dir);
        }
Example #4
0
 public ImageTreeNode2(ImageDirectory dir) : base(dir.name)
 {
     this.dir = dir;
 }
Example #5
0
 public ImageTreeNode(ImageDirectory dir) : base(dir.name)
 {
     this.dir = dir;
     this.UpdateChildNodes();
 }
Example #6
0
        public void dbg_NearImage()
        {
            ImageDirectory overlap = new ImageDirectory("<重複検索>", root);
            Gen::Dictionary <Image, ImageDirectory> groups = new Gen::Dictionary <Image, ImageDirectory>();

            afh.ImageArrange.ProgressDialog progress = new ProgressDialog();
            progress.Title       = "重複比較中 ...";
            progress.ProgressMax = this.sorted.Count;

            progress.Show();
            for (int i = 0; i < this.sorted.Count; i++)
            {
                Image img1 = new Image(this.root, this.sorted[i]);

                if (i % 50 == 0)
                {
                    progress.Description = "画像 '" + img1.thm.filepath + "' の類似画像を探索中 ...";
                    if (progress.IsCanceled)
                    {
                        return;
                    }
                }

                for (int j = i + 1; j < this.sorted.Count; j++)
                {
                    Image img2 = new Image(this.root, this.sorted[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(), root);
                            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();

            this.root.dirs.Add(overlap);
        }