public List <ResultCBIR> computeMinkowskiDistance()
        {
            //Clear result list before adding value
            this.DistancebetweenImage.Clear();
            List <double> selectedImage = new List <double>();

            foreach (RFMethodImageDetails eachImage in allImageDetails)
            {
                string image = eachImage.imageID;
                //if(image==queryImage)
                if (new Uri(image) == new Uri(queryImage))
                {
                    //compute distance between two images ,
                    selectedImage = eachImage.GaussianNormalizedWeight;
                    break;
                }
            }

            foreach (RFMethodImageDetails histogramImage in allImageDetails)
            {
                ResultCBIR dis           = new ResultCBIR();
                int        binNumber     = 0;
                double     totalDistance = 0.0;
                while (binNumber < 89)
                {
                    double queryImage    = selectedImage.ElementAt(binNumber);
                    double databaseImage = histogramImage.GaussianNormalizedWeight.ElementAt(binNumber);
                    RFMethodFeatureDetails featureSet = allFeature.ElementAt(binNumber);
                    double weight   = featureSet.normalizedWeight;
                    double distance = weight * (Math.Abs(queryImage - databaseImage));
                    totalDistance = distance + totalDistance;
                    binNumber++;
                }
                dis.imageid       = histogramImage.imageID;
                dis.totaldistance = totalDistance;
                DistancebetweenImage.Add(dis);
            }
            //Orderby
            DistancebetweenImage = DistancebetweenImage.OrderBy(i => i.totaldistance).ToList();
            return(DistancebetweenImage);
        }
Esempio n. 2
0
        public List <ResultCBIR> computeManhattanDistance(string selecteImageFilePath, List <HistogramBin> histogramBinInensity, string method)
        {
            //Retirieve selected image histogram value
            Dictionary <int, int> selectedImageHistogram = new Dictionary <int, int>();
            List <double>         selectedImage          = new List <double>();
            int totalPixelSelectedImage = 0;

            foreach (HistogramBin image in histogramBinInensity)
            {
                string imageid = image.getImageId();
                if (selecteImageFilePath == null)
                {
                    return(null);
                }
                if (new Uri(imageid) == new Uri(selecteImageFilePath))
                {
                    totalPixelSelectedImage = image.getNumberOfPixelImage();
                    //selected_image histogram
                    if (method == "intensity")
                    {
                        selectedImageHistogram.Clear();
                        selectedImageHistogram = image.getValueHistogram();
                    }
                    else
                    {
                        selectedImageHistogram.Clear();
                        selectedImageHistogram = image.getValueColorCodeHistogram();
                    }
                    foreach (KeyValuePair <int, int> pair in selectedImageHistogram)
                    {
                        selectedImage.Add(pair.Value);
                    }
                    break;
                }
            }


            foreach (HistogramBin images in histogramBinInensity)
            {
                int                   i             = 0;
                double                totalDistance = 0;
                ResultCBIR            dis           = new ResultCBIR();
                Dictionary <int, int> image         = new Dictionary <int, int>();
                int                   condition     = 0;
                if (method == "intensity")
                {
                    image.Clear();
                    image     = images.getValueHistogram();
                    condition = 25;
                }
                else
                {
                    image.Clear();
                    image     = images.getValueColorCodeHistogram();
                    condition = 64;
                }
                int    totalPixel = images.getNumberOfPixelImage();
                string imageID    = images.getImageId();
                dis.imageid = imageID;

                while (i < condition)
                {
                    //look for key in dictionary and store the value
                    double numberOfPixelInBin = image[i];
                    double argument1          = numberOfPixelInBin / totalPixel;

                    double numberOfPixelInSelectedImageBin = selectedImage.ElementAt(i);
                    double argument2 = numberOfPixelInSelectedImageBin / totalPixelSelectedImage;

                    double distance = Math.Abs(argument2 - argument1);

                    totalDistance = totalDistance + distance;
                    i++;
                }

                dis.totaldistance = totalDistance;
                DistancebetweenImage.Add(dis);
            }
            //Orderby
            DistancebetweenImage = DistancebetweenImage.OrderBy(i => i.totaldistance).ToList();
            return(DistancebetweenImage);
        }