Ejemplo n.º 1
0
        //INPUT: An array of integers
        //OUTPUT: An array of doubles normalized between 0 and 1
        public static double[] NormalizeArray(int[] exposure)
        {
            double[] norm_arr = new double[exposure.Length];
            int      min      = int.MaxValue;
            int      max      = 0;

            //1. Find the minimum and maximum values.
            Parallel.For(0, exposure.Length, i =>
            {
                if (exposure[i] < min)
                {
                    min = exposure[i];
                }
                if (exposure[i] > max)
                {
                    max = exposure[i];
                }
            });
            //2. Normalize every pixel to a value between 0 and 1.
            _ = Parallel.For(0, exposure.Length, i =>
            {
                double norm = Auxiliary.Normalize((double)exposure[i], (double)min, (double)max);
                norm_arr[i] = norm;
            });
            return(norm_arr);
        }
Ejemplo n.º 2
0
        //Returns an array of values between 0 and 1.
        //public static double[] NormalizeArray(int[] exposure, double[] normalized)
        //{

        //    int min = int.MaxValue;
        //    int max = 0;

        //    Parallel.For(0, exposure.Length, i =>
        //    {
        //        if (exposure[i] < min) { min = exposure[i]; }
        //        if (exposure[i] > max) { max = exposure[i]; }
        //    });

        //    _ = Parallel.For(0, exposure.Length, i =>
        //    {
        //        double norm = Auxiliary.Normalize(exposure[i], min, max);
        //        normalized[i] = norm;

        //    });
        //    return normalized;
        //}
        //INPUT: An array of doubles
        //OUTPUT: An array of doubles normalized between 0 and 1
        public static double[] NormalizeArray(double[] arr)
        {
            double[] norm_arr = new double[arr.Length];
            double   min      = 99999;
            double   max      = 0;

            Parallel.For(0, arr.Length, i =>
            {
                if (arr[i] < min)
                {
                    min = arr[i]; Console.WriteLine("min: " + min);
                }
                if (arr[i] > max)
                {
                    max = arr[i]; Console.WriteLine("max: " + max);
                }
            });
            _ = Parallel.For(0, norm_arr.Length, i =>
            {
                double norm = Auxiliary.Normalize(arr[i], min, max);
                norm_arr[i] = norm;
            });
            return(norm_arr);
        }