If we want to lowpass filter an image by 0.3xpi rad/sample
by using h = fspecial('average', size)
, how shall we determine size
parameter corresponding to 0.3xpi rad/sample
in the following code?
lp_filter = fspecial('average', size);
img = imfilter(original,lp_filter,'replicate');
Filter size is the inverse of the cut-off. So, for a simple filter like average, if you had a size of 1 pixel (i.e. no averaging), the cut-off would be at pi rad/sample. So, the nearest integer to 0.3 pi rad/sample would be a size of 3 pixels.
The maths is a bit more complicated than that, but this is a useful rule of thumb in this case.