描述:之所以我把它翻译成最值滤波器,因为它的原理就是在卷积核区域内,中心点的值如果大于或小于附近值的最大值或最小值时,将大于最大值的赋值为最大值,将小于最小值的赋值为最小值,这就是Conservative Smoothing Filter
如下图所示:
这上面的图表明中间点150要换成127,简单点讲就是大于最大值的等于最大值,小于最小值的等于最小值,在最小值和最大值之间的值不变。
Code:
/**
* Finds the maximum value from a 3x3 pixel neighbourhood overlaid with
* a 3x3 kernel (on/off). The centre pixel of the kernel is ignored.
*
* @param input The 2D array of pixel values representing the image.
* @param kernel The array representing the kernel.
* @param w The width of the image.
* @param h The height of the image.
* @param x The x coordinate of the centre of the 3x3 neighbourhood.
* @param y The y coordinate of the centre of the 3x3 neighbourhood.
* @return The maximum value.
*/
public static int maxNeighbour(int [][]