예제 #1
0
        public override Image Sobel()
        {
            Image            input           = Clone().ToGray();
            GenericImage <T> verticalSobel   = (GenericImage <T>)input.Filter(KernelFactory.SobelVertical(), FilterType.AVERAGE);
            GenericImage <T> horizontalSobel = (GenericImage <T>)input.Filter(KernelFactory.SobelHorizontal(), FilterType.AVERAGE);
            GenericImage <T> outcome         = verticalSobel.Add(horizontalSobel);

            return(outcome);
        }
예제 #2
0
        internal override GenericImage <T> Add(GenericImage <T> other)
        {
            ImageRGB <T> outcome  = (ImageRGB <T>)ImageFactory.Create(Width, Height, GetColorModel(), GetDataType());
            ImageRGB <T> otherRGB = (ImageRGB <T>)other.ToRGB();

            outcome.R = R.Add(otherRGB.R);
            outcome.G = G.Add(otherRGB.G);
            outcome.B = B.Add(otherRGB.B);
            return(outcome);
        }
예제 #3
0
        internal void Average(GenericChannel <T> originalChannel, GenericImage <T> .KernelFunction kernelFunction, uint x, uint y, uint kernelSize)
        {
            double          sum            = 0;
            Action <double> filterFunction = (p) =>
            {
                sum += p;
            };

            kernelFunction(originalChannel, x, y, filterFunction);
            T average = ConvertFromDouble(sum);

            Pixels[x, y] = average;
        }
예제 #4
0
        internal void Minimum(GenericChannel <T> originalChannel, GenericImage <T> .KernelFunction kernelFunction, uint x, uint y, uint kernelSize)
        {
            uint            totalCount     = kernelSize * kernelSize;
            double          min            = double.MaxValue;
            Action <double> filterFunction = (p) =>
            {
                if (p <= min)
                {
                    min = p;
                }
            };

            kernelFunction(originalChannel, x, y, filterFunction);
            min         *= totalCount;
            Pixels[x, y] = ConvertFromDouble(min);
        }
예제 #5
0
        internal void Maximum(GenericChannel <T> originalChannel, GenericImage <T> .KernelFunction kernelFunction, uint x, uint y, uint kernelSize)
        {
            uint            totalCount     = kernelSize * kernelSize;
            double          max            = 0.0;
            Action <double> filterFunction = (p) =>
            {
                if (p >= max)
                {
                    max = p;
                }
            };

            kernelFunction(originalChannel, x, y, filterFunction);
            max         *= totalCount;
            Pixels[x, y] = ConvertFromDouble(max);
        }
예제 #6
0
        internal void Median(GenericChannel <T> originalChannel, GenericImage <T> .KernelFunction kernelFunction, uint x, uint y, uint kernelSize)
        {
            uint totalCount = kernelSize * kernelSize;

            double[]        pixels         = new double[totalCount];
            byte            count          = 0;
            Action <double> filterFunction = (p) =>
            {
                pixels[count] = p;
                count++;
            };

            kernelFunction(originalChannel, x, y, filterFunction);
            Array.Sort(pixels);
            double median = pixels[count / 2] * totalCount;

            Pixels[x, y] = ConvertFromDouble(median);
        }
예제 #7
0
        internal void Range(GenericChannel <T> originalChannel, GenericImage <T> .KernelFunction kernelFunction, uint x, uint y, uint kernelSize)
        {
            uint            totalCount     = kernelSize * kernelSize;
            double          max            = 0.0;
            double          min            = double.MaxValue;
            Action <double> filterFunction = (p) =>
            {
                if (p >= max)
                {
                    max = p;
                }

                if (p <= min)
                {
                    min = p;
                }
            };

            kernelFunction(originalChannel, x, y, filterFunction);
            double range = (max - min) * totalCount;

            Pixels[x, y] = ConvertFromDouble(range);
        }
예제 #8
0
 internal abstract GenericImage <T> Add(GenericImage <T> other);