I am trying to implement dilation filter for SVG Morphology filter.
The documentation says dilation (or erosion) kernel is a rectangle with a width of 2*x-radius and a height of 2*y-radius. In dilation, the output pixel is the individual component-wise maximum of the corresponding R,G,B,A values in the input image's kernel rectangle.
https://www.w3.org/TR/SVG/filters.html#feMorphologyElement
I couldn't really find out what should be the kernel in this case. Can you please give some pointers?
Is it really equivalent to finding local maxima of below region for each pixel in input image?
int startX = std::max( pixelCordX - radiusX, 0 );
int endX = std::min( pixelCordX + radiusX, width - 1 );
int = std::max( pixelCordY - radiusY, 0 );
int endY = std::min( pixelCordY + radiusY, height - 1 );
outputPixel( pixelCordX , pixelCordY ) = ComputeMaxMin( image[][], startX, endX, startY, endY );
Loop through all pixels in the rectangle, keeping track of the maximum value for each of R,G,B and A. Combine the maximum value of each component into a single colour value, and make that the centre pixel colour.