MATLAB Answers


Calculating perimeter of regions in binary image using matlab

Asked by Safaa
on 5 Dec 2012

Hi all:

I am trying to calculate perimeter of regions in binary image using matlab. I am using the following code:

perimeter_stats = regionprops(binary_image,'Perimeter');

allPerimeter= [perimeter_stats.Perimeter];

The problem is in the results. The image contains large regions but the calculated perimeter is small (e.g. 3.2092). Can anyone help me in getting the right values of perimeter?




1 Answer

Answer by Image Analyst
on 5 Dec 2012
 Accepted answer

Well you did something wrong. I doubt that the mean of allPerimeter is 3.2092 pixels. Why don't you list what allPerimeter is so I can see it. I would think that the minimum a perimeter could be is 1 pixel, but it's typically in the hundreds or thousands, not 3 unless your binary image is just a single dot.


Did you notice the 1.0e003 in there? You multiply that by the numbers. This is not related to regionprops - that is how all of MATLAB works. So the actual perimeters are [3209.2, 802.9, 992.9, 189.5, etc. These are quite reasonable numbers. There is no problem at all.

on 8 Dec 2012

Many thanks for your clarification

So did that answer your question? Are you ready to mark this as "Answered", or is it still not solved for you?

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!