fspecial -Disk filter -Algorithm

I'm trying to understand how matlab creates its disk filter function. In a continuous domain, a disk is just 1 inside some radius and 0 outside that radius.
The tricky part about making the disk function with an image is that the edge pixels may be partially inside the disk and partially outside the disk. It appears that the matlab function assigns the edge pixels a value equal to the area of the pixel contained in the disk.
I've been trying to derive the algorithm for how one would do that, but it seems that this isn't straight forward. Is there a paper or textbook detailing how to create the disk function seen in the fspecial function? Is this problem much easier than I think it is?

回答 (1 件)

Image Analyst
Image Analyst 2014 年 9 月 19 日

1 投票

Because it's a digital computer, the circle has to be digitized/quantized. See the FAQ for an algorithm: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F

7 件のコメント

Nicholas
Nicholas 2014 年 9 月 19 日
The FAQ isn't even close to answering my question. It discusses creating a binary mask, an image of strctly 1's and 0's. I'm specifically asking about an algorithm that would partially weight edge pixels so that it still creates an image that looks circular when the number of pixels is small.
Image Analyst
Image Analyst 2014 年 9 月 19 日
As far as I know bwarea() is the only image processing function that takes into account possible non-digitized nature of the underlying image.
Perhaps you can attach an image to illustrate what you mean. Mock something up in Photoshop of you have to.
Nicholas
Nicholas 2014 年 9 月 22 日
Hey Image Analyst,
Here is the output of fspecial('disk', 2). This is what a discrete disk function looks like when the radius is only 2 pixels. Notice the central pixels have the maximum value and the border pixels have intermediate values. I'm looking for an explanation of the algorithm, possibly a reference.
Nicholas
Nicholas 2014 年 9 月 22 日
The light green pixels are a little less than half-in/half-out of the circle, the red pixels are fully inside, and the dark blue pixels are completely outside of the circle.
Image Analyst
Image Analyst 2014 年 9 月 22 日
You can see the algorithm by bringing fspecial up in the editor:
>> edit fspecial
Nicholas
Nicholas 2014 年 9 月 23 日
I can see the algorithm, but the algorithm is complicated and I'd like an explanation of the geometry. I wasn't able to derive the algorithm. I'm after a reference or a derivation.
Image Analyst
Image Analyst 2014 年 9 月 23 日
It probably is a typical anti-aliasing routine where you "feather" the edges according to how much of the square tile circle would be taken up by a perfect circle. So if the circle would cover 30% of the square, it will have 30% of the solid, interior value.

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

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

質問済み:

2014 年 9 月 19 日

コメント済み:

2014 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by