Exemple #1
0
        private double[,] Fuzzify(byte[,] input)
        {
            var stats        = new ImageStatistics(Input.Image);
            int minGrayLevel = stats.Gray.Min;

            maxGrayLevel = stats.Gray.Max;
            if (crossoverPoint == -1)
            {
                crossoverPoint = (byte)(maxGrayLevel - minGrayLevel) / 2 + minGrayLevel;
            }

            denominationalFuzzifier = CalculateDenominationalFuzzifier(crossoverPoint, (byte)maxGrayLevel);

            double[,] result = input.ApplyTransform((Func <byte, double>)MembershipFunction);
            return(result);
        }
        public override AlgorithmResult ProcessData()
        {
            var stats   = new ImageStatistics(Input.Image);
            int minGray = stats.Gray.Min;
            int maxGray = stats.Gray.Max;

            byte[,] pixels               = Input.Image.GetPixels();
            double[,] memberships        = pixels.ApplyTransform(x => MembershipFunction(x, minGray, maxGray));
            double[,] modifiedMembership = memberships.ApplyTransform(MembershipModification);
            byte[,] newValues            = modifiedMembership.ApplyTransform(Defuzzyfication).NarrowToBytes();
            Input.Measure = FuzzyMeasures.Fuzz(memberships);
            return(new AlgorithmResult(newValues)
            {
                Measure = FuzzyMeasures.Fuzz(modifiedMembership)
            });
        }