コード例 #1
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;
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public override GenericChannel <uint> Add(GenericChannel <uint> other)
        {
            ChannelUInt32 outcome = new ChannelUInt32(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    long newValue = (long)this[x, y] + other[x, y];
                    if (newValue > uint.MaxValue)
                    {
                        newValue = uint.MaxValue;
                    }
                    outcome[x, y] = (uint)newValue;
                }
            }
            return(outcome);
        }
コード例 #5
0
        public override GenericChannel <double> Add(GenericChannel <double> other)
        {
            ChannelDouble outcome = new ChannelDouble(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    double newValue = this[x, y] + other[x, y];
                    if (newValue > 1.0)
                    {
                        newValue = 1.0;
                    }
                    outcome[x, y] = newValue;
                }
            }
            return(outcome);
        }
コード例 #6
0
        public override GenericChannel <byte> Add(GenericChannel <byte> other)
        {
            ChannelUInt8 outcome = new ChannelUInt8(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    int newValue = this[x, y] + other[x, y];
                    if (newValue > byte.MaxValue)
                    {
                        newValue = byte.MaxValue;
                    }
                    outcome[x, y] = (byte)newValue;
                }
            }
            return(outcome);
        }
コード例 #7
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);
        }
コード例 #8
0
        public override GenericChannel <ushort> Add(GenericChannel <ushort> other)
        {
            ChannelUInt16 outcome = new ChannelUInt16(Width, Height);

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    int newValue = this[x, y] + other[x, y];
                    if (newValue > ushort.MaxValue)
                    {
                        newValue = ushort.MaxValue;
                    }
                    outcome[x, y] = (ushort)newValue;
                }
            }
            return(outcome);
        }
コード例 #9
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);
        }
コード例 #10
0
 public abstract GenericChannel <T> Add(GenericChannel <T> other);