Class MedianKernel
- java.lang.Object
-
- dev.brachtendorf.jimagehash.hashAlgorithms.filter.Kernel
-
- dev.brachtendorf.jimagehash.hashAlgorithms.filter.NonAveragingKernel
-
- dev.brachtendorf.jimagehash.hashAlgorithms.filter.MedianKernel
-
- All Implemented Interfaces:
Filter,Serializable
public class MedianKernel extends NonAveragingKernel
A median kernel is a non linear filter scanning the image and replacing every value with the median value found in the neighborhood. This median kernel allows a weight matrix to be supplied.Example 1D kernel width 5 Kernel and no/uniform mask
Values: 5 4 1 3 61 3 4 5 6 During convolution, the kernel looks at the value 1 and replaces it with the value 4 due to it being the median.A weight mask
[1 2 3 2 1]can give more emphasis on closer pixel values. An intermediary value matrix is calculated:Values * Mask = [5 8 3 6 6]
3 5 6 6 8 and it is found that the second value is the maximum. Now the unaltered vlaue at position 2 is taken. Therefore the 1 is replaced with the value 4.- Since:
- 2.0.0
- Author:
- Kilian
- See Also:
MedianKernel,MinimumKernel, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.filter.Kernel
Kernel.EdgeHandlingStrategy, Kernel.GrayScaleFilter
-
-
Field Summary
-
Fields inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.filter.Kernel
edgeHandling, mask
-
-
Constructor Summary
Constructors Constructor Description MedianKernel(double[][] mask)Create a kernel with the given masks dimension.MedianKernel(int width, int height)Create a median kernel with a uniform weight mask (no weighting takes place)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doublecalcValue(byte[][] input, int x, int y)protected doublecalcValue(double[][] input, int x, int y)protected doublecalcValue(int[][] input, int x, int y)BufferedImagefilter(BufferedImage input)Apply the filter to the input image and return an altered copyprotected doubleresolveMedian(double[][] values)-
Methods inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.filter.NonAveragingKernel
computePotentialValues, computePotentialValues, computePotentialValues
-
Methods inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.filter.Kernel
apply, apply, apply, applyByte, applyByte, applyInt, applyInt, boxFilter, boxFilterNormalized, boxFilterNormalizedSep, edgeDetectionFilter, embossHorizontontalFilter, embossLeftDiagonalFilter, embossleftRightFilter, embossRightDiagonalFilter, equals, gaussianFilter, hashCode, identityFilter, toString, zeroFilter
-
-
-
-
Constructor Detail
-
MedianKernel
public MedianKernel(int width, int height)Create a median kernel with a uniform weight mask (no weighting takes place)- Parameters:
width- of the kernel. has to be oddheight- of the kernel. has to be odd
-
MedianKernel
public MedianKernel(double[][] mask)
Create a kernel with the given masks dimension. The masks acts as weight filter increasing or decreasing the weight of the value during convolution. For an example see the javadoc of the class.- Parameters:
mask- weight matrix used to judge which value is the maximum
-
-
Method Detail
-
calcValue
protected double calcValue(byte[][] input, int x, int y)
-
calcValue
protected double calcValue(int[][] input, int x, int y)
-
calcValue
protected double calcValue(double[][] input, int x, int y)
-
resolveMedian
protected double resolveMedian(double[][] values)
-
filter
public BufferedImage filter(BufferedImage input)
Description copied from interface:FilterApply the filter to the input image and return an altered copy
-
-