Circular patch using COLFILT?
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
Sean de Wolski
2013-11-4
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))
0 个评论
Image Analyst
2013-11-4
To do that, (max-min), it looks like you can use rangefilt().
1 个评论
Sean de Wolski
2013-11-4
Yeah, actually:
F = floor(rangefilt(I,getnhood(strel('disk',r)))./r)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!