Different Euler Numbers from regionprops and bweuler

  • Follow


I have two cases where the calculation of Euler Number using
4-connected neighborhoods that is done using regionprops and with
bweuler are different (0 and 1 in one case, -1 and 1 in the other).

  Why would they every be different?

  To calcluate Euler Number using regionprops, I read in a binary
file into I using imread. I label the areas and find the largest
area (there`s only one in this case). Then, I calculate the number.
Here is the code:

[I,map] = imread([filename '.png']);
[L,num_areas] = bwlabel(I,4);
area = regionprops(L,'Area');
[biggest_area,big_area] = max([area.Area]);
Euler_Number = regionprops(L,'EulerNumber');
Euler_Number(big_area).EulerNumber

  Here is the line using bweuler:

Euler_Number = bweuler(I,4)

  In each case, there is only one region in the image.

                                                                     
          Thanks, Alan
0
Reply jalanthomas (125) 6/25/2007 5:51:35 PM

Alan wrote:
> I have two cases where the calculation of Euler Number using
> 4-connected neighborhoods that is done using regionprops and with
> bweuler are different (0 and 1 in one case, -1 and 1 in the other).
> 
>   Why would they every be different?
> 
>   To calcluate Euler Number using regionprops, I read in a binary
> file into I using imread. I label the areas and find the largest
> area (there`s only one in this case). Then, I calculate the number.
> Here is the code:
> 
> [I,map] = imread([filename '.png']);
> [L,num_areas] = bwlabel(I,4);
> area = regionprops(L,'Area');
> [biggest_area,big_area] = max([area.Area]);
> Euler_Number = regionprops(L,'EulerNumber');
> Euler_Number(big_area).EulerNumber
> 
>   Here is the line using bweuler:
> 
> Euler_Number = bweuler(I,4)
> 
>   In each case, there is only one region in the image.
> 
>                                                                      
>           Thanks, Alan

regionprops always performs the Euler number computation using 
8-connected neighborhoods.

-- 
Steve Eddins
http://blogs.mathworks.com/steve
0
Reply steve.eddins (783) 6/25/2007 6:40:19 PM


Steve Eddins wrote:
>
> regionprops always performs the Euler number computation using
> 8-connected neighborhoods.
>

   I did not see this in the documentation. Also, it would be good
in the future if MATLAB supported both, for flexibility and for
compatibility with whole image Euler Number calculation.

Alan
0
Reply jalanthomas (125) 6/25/2007 10:52:46 PM

Alan wrote:
> Steve Eddins wrote:
>> regionprops always performs the Euler number computation using
>> 8-connected neighborhoods.
>>
> 
>    I did not see this in the documentation. Also, it would be good
> in the future if MATLAB supported both, for flexibility and for
> compatibility with whole image Euler Number calculation.
> 
> Alan

I'll make a note about adding that information to the doc.

I take your point about flexibility, but I'm not sure what you mean by 
compatibility.  The default connectivity used by bweuler is 8, which is 
consistent with what regionprops does.

-- 
Steve Eddins
http://blogs.mathworks.com/steve
0
Reply steve.eddins (783) 6/26/2007 1:17:04 AM

Steve Eddins wrote:
> I take your point about flexibility, but I'm not sure what you mean
> by
> compatibility. The default connectivity used by bweuler is 8,
> which is
> consistent with what regionprops does.

  Just that it would make more sense if regionprops and bweuler
worked the same way, letting the user specify whether to use 4 or 8.


    Thanks, Alan
0
Reply jalanthomas (125) 6/26/2007 1:34:26 AM

4 Replies
35 Views

(page loaded in 0.045 seconds)


Reply: