Circular patch using COLFILT?

Hi there,
COLFILT operates a function on a matrix/image within a rectangular patch of [m n]. Instead of a rectangular one; I want my function to operate within a circular disc/mask. Is there a way to do it?
Example:
r = 5; % a certain length
rc = @(x) floor(((max(x)-min(x))/r))+ 1; % a non-linear filter
F= colfilt(I, [r r],'sliding', rc); % I is my 2D matrix/image
Query: Here, if I want to have a disk of radius r, instead of a rectangle [r r], how I do that?

回答 (2 件)

Sean de Wolski
Sean de Wolski 2013 年 11 月 4 日

1 投票

Inside of your anonymous function, you could use logical indexing to only apply the operation to the circular part of the rectangular. As for generating the circle, an easy way:
M = getnhood(strel('disk',r))
Image Analyst
Image Analyst 2013 年 11 月 4 日

0 投票

To do that, (max-min), it looks like you can use rangefilt().

1 件のコメント

Sean de Wolski
Sean de Wolski 2013 年 11 月 4 日
Yeah, actually:
F = floor(rangefilt(I,getnhood(strel('disk',r)))./r)

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

質問済み:

2013 年 11 月 4 日

コメント済み:

2013 年 11 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by