Best approach of special sort of filtering

1 回表示 (過去 30 日間)
Mohammad Abouali
Mohammad Abouali 2014 年 9 月 19 日
コメント済み: Mohammad Abouali 2014 年 9 月 19 日
Let's say we have a single layer of data of size MxN and we want to filter it and let's say the filter size is 11x11.
If we could write our filter in matrix form, such as average, we would do something like this:
h=fspecial('average',11)
I_filtered=imfilter(I,h);
But let's say we can not write the filter in a simple matrix, but we have a function handle for it. How can I apply that to the image? One approach is to use the block proc as follow:
I_Filtered=blockproc(I,[1,1],filter_function_handle,'BorderSize',[10,10],'PadPartialBlocks',true,'PadMethod','symmetric','TrimBorder',false);
That would do the job, but I was wondering if there is another way of applying such filter to image? Any thoughts are appreciated.

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 19 日
blocproc() moves in "jumps" of the window size, unless you take special precautions. What you want is nlfilter(), which slides along a pixel at a time.
See demo attached below.
  1 件のコメント
Mohammad Abouali
Mohammad Abouali 2014 年 9 月 19 日
I know blockproc jumps. That's why I set the block size to [1 1] and then border size to [10 10]. That simulates exactly as the window is sliding although in fact it is jumping.
But nlfilter is the one that I was looking for. Thank you for that.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by