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); }
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); }
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; }
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); }
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); }
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); }
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); }
internal abstract GenericImage <T> Add(GenericImage <T> other);