MATLAB: How to get the Euler number of a binary matrix

eulerImage Processing Toolboxroc

Hi , i`ve never programmed in matlab before and I want to calculate the Euler Number of a binary matrix such as
0001000
0001000
0001000
0001000
I hope that my question is clear.
Thank You.

Best Answer

Try this (if you have the Image Processing Toolbox):
measurements = regionprops(binaryMatrix, 'EulerNumber');
EulerNumbers = [measurements.EulerNumber];
Related Question