How to find the area of a segmented image in matlab?
Mostra commenti meno recenti
I need to find the total area of the segmented image(attached below) in Matlab. However i am not able to get that if i use regionprops('Area') command. It gives me total pixel size which is 2048*2048 but i need to find the area of only the segmented region(Black)? Please tell me how to do it.
2 Commenti
Sreenath Reddy
il 11 Nov 2020
can u add full source code please to find the area
Rik
il 11 Nov 2020
Have you looked at the answers below?
Risposta accettata
Più risposte (1)
Image Analyst
il 17 Lug 2019
You need to invert your image so that your black region of interest is white. Then call sum() to get the number of pixels:
numberOfBlackPixels = sum(~binaryImage(:));
Or you can get a different area from a different method using bwarea(), which takes into account the shape of the boundary to get like half pixels or whatever:
numberOfBlackPixels = bwarea(~binaryImage);
Or you can use regionprops():
props = regionprops(~binaryImage, 'area');
numberOfBlackPixels = props.Area;
3 Commenti
Ramanathan Anandarama Krishnan
il 18 Lug 2019
Modificato: Ramanathan Anandarama Krishnan
il 18 Lug 2019
Image Analyst
il 18 Lug 2019
My answer is correct (Rik mistake was forgetting to invert the image, or else you said you wanted the black instead of the white after he answered) and the answer is in pixels. If you want to have the answer in cm or square cm you'll have to multiply by a factor, like
areaInCm = areaInPixels * cmPerPixel ^2;
See attached demo for a full example. If I helped you please Vote for or Accept the answer.
Ramanathan Anandarama Krishnan
il 18 Lug 2019
Categorie
Scopri di più su Image Processing Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!