How does fspecial average filter deal with overlap causes by edges of an image?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am applying an average filter using the fspecial command. I am wondering how the average filter works on images whose dimensions are not multiples of the user-specified hsize. For example if a 3x3 filter is chosen and applied to a 10x10 pixel image, how does this filter deal with the last row and column?
0 comentarios
Respuesta aceptada
Thorsten
el 15 de En. de 2013
The filter is always centered on the pixel to be processed. At the boundary, missing values are by default replaced by zero.
imfilter(ones(10), ones(3))
Other boundary conditions can be found at the help of imfilter, e.g., 'replicate', which takes the missing values from the nearest border pixel:
imfilter(ones(10), ones(3), 'replicate')
2 comentarios
Thorsten
el 18 de En. de 2013
Editada: Thorsten
el 18 de En. de 2013
Its includes all 3 x 3 pixels. OUTPUTIMAGE = imfilter(IMAGE, FILTER) works as follows: Center the FILTER on pixel (i, j) of IMAGE. Then weight every pixel of IMAGE with the values in FILTER at corresponding positions and sum all these values. Assign the summed value to OUTPUTIMAGE(i,j). Do this for all pixels in IMAGE.
Please do not forget to accept an answer.
Más respuestas (2)
David
el 15 de En. de 2013
fspecial will just define the 3x3 filter you're using and imfilter is the function that actually applies it to the image. imfilter deals with the last row and column in the same way whatever the size of the input image.
Don't think of your 10x10 image as being divided in to 3x3 subsets, because it isn't. The filter is applied to every pixel individually: pixel (1,1), then (1,2), then (1,3), and every other pixel. Think of the filter as being applied to overlapping subsets, each position shifted by one pixel.
If you have some curious artefacts at the edge, consider the boundary options (see help imfilter).
0 comentarios
Image Analyst
el 18 de En. de 2013
fspecial() is not a filter. It is a kernel maker, a filter maker. You then use this kernel (filter) in a function that does the actual filtering, such as imfilter(), or conv2(). There are explanations of the "boundary or edge effects" in the help for those functions. There are different ways you can choose to handle the output value when the filter window falls off the edge of the image.
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!