Beispiel #1
0
        public Dictionary <int, float> getCRHistogram(Bitmap img, bool isCenter, float centering)
        {
            CenteringRefinement cr = new CenteringRefinement(img, centering);
            int imgDimensions      = cr.getDimensions(isCenter);

            return(quantizeColors(convertToLuv(cr.getRgbHistogram(isCenter)), imgDimensions));
        }
Beispiel #2
0
        public List <String> returnRelevantImages(Bitmap image, bool center)
        {
            Bitmap img = new Bitmap(image);
            //bool center = true;
            CenteringRefinement cr = new CenteringRefinement(img, centering);

            imgDimensions = cr.getDimensions(center);

            quantizedHistogram = ch.getCRHistogram(img, center, centering);

            foreach (int x in quantizedHistogram.Keys)
            {
                normalizedHistogram.Add(x, quantizedHistogram[x] / imgDimensions);
            }

            for (int i = 0; i < 159; i++)
            {
                normalizedHistogram.TryGetValue(i, out hist1[i]);
            }

            foreach (String s in imagePaths)
            {
                paths.Add(s);
            }

            // Loop for currentImg
            foreach (String s in paths)
            {
                Dictionary <int, float> currQuantizedHistogram  = new Dictionary <int, float>();
                Dictionary <int, float> currNormalizedHistogram = new Dictionary <int, float>();
                Bitmap currImg = new Bitmap(s);

                // CH with Centering Refinement
                CenteringRefinement cr2 = new CenteringRefinement(currImg, centering);
                //bool cent = false;

                currImgDimensions      = cr2.getDimensions(center);
                currQuantizedHistogram = ch.getCRHistogram(img, center, centering);

                sim = 0;

                foreach (int x in currQuantizedHistogram.Keys)
                {
                    currNormalizedHistogram.Add(x, currQuantizedHistogram[x] / currImgDimensions);
                }

                for (int i = 0; i < 159; i++)
                {
                    currNormalizedHistogram.TryGetValue(i, out hist2[i]);
                }

                sim = ch.computeSimilarity(hist1, hist2, threshold);
                if (sim > simThreshold)
                {
                    similarImagesPaths.Add(s);
                }

                //Debug.WriteLine(sim);
                if (center)
                {
                    centeredSim.Add(sim);
                }
                else
                {
                    nonCenteredSim.Add(sim);
                }
            }

            return(similarImagesPaths);
        }