Calculating perimeter of regions in binary image using matlab

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?
Regards,
Safaa

 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.

5 Comments

Actually this number is an example of a calculated perimeter for one region in the image. Other calculated values for other regions are between 1.xxx and 3.xxx . I didn't calculate the mean. Those illogical values occur only when calculating perimeter. Results are logical when calculating other properties such as area and diameter.
This is the result :
Perimeter feature 1.0e+003 *
Columns 1 through 16
3.2092 0.8029 0.9929 0.1895 0.5892 0 1.1393 0 0.5312 0.3656 1.7511 0.7024 0.4718 0.2520 1.9389 0.6087
Columns 17 through 19
0.3915 0.3507 0.5460
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.
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?

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!