//After standarddeviation and mean value are calculted for each bin then


        public void computeGaussianNormalizedWeight(double minValue)
        {
            while (currentImageId < 100)
            {
                Dictionary <int, double> imageHistogram = allImageHistogramRfMethod.ElementAt(currentImageId).getHistogramBinRfMethod();
                string imageID = allImageHistogramRfMethod.ElementAt(currentImageId).imageID;
                //new IMageDetails for each image
                RFMethodImageDetails imageDetails = new RFMethodImageDetails();
                //Every image has a unique id - fileapth of image
                imageDetails.imageID = imageID;
                //Every image has a histogram
                imageDetails.ImageHistogram = imageHistogram;
                foreach (KeyValuePair <int, double> pair in imageHistogram)
                {
                    double gaussianNormalizedWeight = 0.0;
                    double meanValue                     = 0.0;
                    double standardDeviation             = 0.0;
                    int    binNumber                     = pair.Key;
                    RFMethodFeatureDetails featureValues = allFeature.ElementAt(binNumber);
                    meanValue         = featureValues.meanValue;
                    standardDeviation = featureValues.standardDeviation;
                    if (standardDeviation == 0)
                    {
                        //check mean value
                        if (meanValue == 0)
                        {
                            gaussianNormalizedWeight = 0.0;//set gaussiannormalized weight to 0
                            imageDetails.GaussianNormalizedWeight.Add(gaussianNormalizedWeight);
                        }
                        else
                        {
                            standardDeviation        = 0.5 * minValue;
                            gaussianNormalizedWeight = (double)((pair.Value - meanValue) / standardDeviation);
                            imageDetails.GaussianNormalizedWeight.Add(gaussianNormalizedWeight);
                        }
                    }
                    else
                    {
                        gaussianNormalizedWeight = (double)((pair.Value - meanValue) / standardDeviation);
                        //Each image has 89 Gaussiannormalized weight(computed only once) for each bin, adding one item in a list at a time
                        imageDetails.GaussianNormalizedWeight.Add(gaussianNormalizedWeight);
                    }
                }
                allImageDetails.Add(imageDetails);
                currentImageId++;
            }
        }
 //In each iteration for each feature calculate mean value,standard deviation, weight and updated weight
 public void addFeatureValues()
 {
     //ADD average value and standard deviation of each bin
     while (currentFeature < 89)
     {
         RFMethodFeatureDetails feature = new RFMethodFeatureDetails();
         //1) compute mean value
         double average = calculateMeanValue();
         feature.meanValue = average;
         //2)compute standard deviation
         double standardDeviation = computeStandardDeviation(average);
         feature.standardDeviation = standardDeviation;
         //feature.updatedWeight = computeUpdatedWeight(standardDeviation,average);
         //ID assigned to each bin from 1-89
         feature.featureID = currentFeature;
         //Add each feature details in one place i.e. List of RFMethodFeatureDetails type
         allFeature.Add(feature);
         currentFeature++;
     }
 }
        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);
        }