コード例 #1
0
        public void GetDirectories(string path)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            bool?          result         = openFileDialog.ShowDialog();

            if (result == true)
            {
                FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
                m = new Myimage {
                    ImagePath = fileInfo.FullName, Hash = 0, DirectoryPath = ""
                };
                Uri uriSource1 = new Uri(fileInfo.FullName);
                bm1 = new BitmapImage();
                bm1.BeginInit();
                bm1.CacheOption   = BitmapCacheOption.OnLoad;
                bm1.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                bm1.UriSource     = uriSource1;
                bm1.EndInit();
                CheckHash(rb1, rb2, rb3, rb4, bm1, m);
                string[] dirs = Directory.GetDirectories(path);
                imglist = new List <Myimage>();
                foreach (var t in dirs)
                {
                    string[] fullfilesPath = Directory.GetFiles(t, "*.jpg", SearchOption.AllDirectories);
                    fullfilesPath = fullfilesPath.Concat(Directory.GetFiles(t, "*.png", SearchOption.AllDirectories)).ToArray();
                    fullfilesPath = fullfilesPath.Concat(Directory.GetFiles(t, "*.bmp", SearchOption.AllDirectories)).ToArray();
                    fullfilesPath = fullfilesPath.Concat(Directory.GetFiles(t, "*.jpeg", SearchOption.AllDirectories)).ToArray();
                    List <Myimage> temp = new List <Myimage>();
                    for (int i = 0; i < fullfilesPath.Length; i++)
                    {
                        temp.Add(new Myimage {
                            ImagePath = fullfilesPath[i], Hash = 0, DirectoryPath = t
                        });
                        Uri uriSource = new Uri(temp[i].ImagePath);
                        bm1 = new BitmapImage();
                        bm1.BeginInit();
                        bm1.CacheOption   = BitmapCacheOption.OnLoad;
                        bm1.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                        bm1.UriSource     = uriSource;
                        bm1.EndInit();
                        CheckHash(rb1, rb2, rb3, rb4, bm1, temp[i]);
                    }
                    imglist.AddRange(temp);
                }
                Stolp st = new Stolp(imglist, dirs);
                st.Check();
                // to check quality
                //   st.Quality();

                m.DirectoryPath = st.Recognize(m);
                MessageBox.Show(m.DirectoryPath);
            }
            else
            {
                MessageBox.Show("Please choose a picture");
            }
        }
コード例 #2
0
ファイル: Stolp.cs プロジェクト: juliasin/SimilarByHashes
            public Arrays(Stolp parent, List <Myimage> ob, List <List <Myimage> > obs)
            {
                minn  = new double[ob.Count];
                minn1 = new double[obs.Count][];
                W     = new double[obs.Count][];
                d     = new List <Dist>();
                for (int i = 0; i < obs.Count; i++)
                {
                    d.Add(new Dist());
                }


                if (ob.Count != 0)
                {
                    dist = new double[ob.Count][];
                    for (int i = 0; i < ob.Count; i++)
                    {
                        dist[i] = new double[ob.Count];
                    }
                    parent.DistAtOneClass(ob.Count, dist, ob);
                    //min = new double[ob.Count];
                    for (int i = 0; i < ob.Count; i++)
                    {
                        minn[i] = parent.MinAtTwo(dist, ob.Count, ob.Count, i);
                    }
                }

                List <double[][]> distt1 = new List <double[][]>();

                for (int i = 0; i < obs.Count; i++)
                {
                    if ((ob.Count != 0) && (obs[i].Count != 0))
                    {
                        d[i].distt1 = new double[ob.Count][];
                        // distt1[i] = new double[ob.Count][];
                        for (int j = 0; j < ob.Count; j++)
                        {
                            d[i].distt1[j] = new double[obs[i].Count];
                        }
                        parent.DistBetwTwoClasses(ob.Count, obs[i].Count, d[i].distt1, ob, obs[i]);
                        minn1[i] = new double[ob.Count];
                        for (int j = 0; j < ob.Count; j++)
                        {
                            minn1[i][j] = parent.MinAtTwo(d[i].distt1, ob.Count, obs[i].Count, j);
                        }
                        W[i] = new double[ob.Count];
                        for (int j = 0; j < ob.Count; j++)
                        {
                            W[i][j] = minn[j] / minn1[i][j];
                        }
                    }
                }
            }