How to print regionprops properties on image?

4 views (last 30 days)
Dear All,
I want to print each labeled region area on the image it self? I calculated label matrix and regionprops matrix using area.
g=regionprops(LB,'Area');
>> g(19)
ans =
Area: 166
Then I want to print these area on image it self. (pixel width is 0.07).
Like this picture.
Thanks for helping
Regards
Chamara

Accepted Answer

Walter Roberson
Walter Roberson on 7 Dec 2015
Edited: Walter Roberson on 7 Dec 2015
Does the label need to go in the image, or can it go over the image?
If it can go over the image, then as well as asking for the regionprops Area, also ask for the Centroid, and then text() the Area to the location given by the Centroid. text() will draw over the image.
If you need to create a new image that has the text "burned in" then if you have the Computer Vision Toolbox then there is a insertText() function, or you can use the older Vision.TextInserter for now.
  1 Comment
sacprasanna
sacprasanna on 7 Dec 2015
Edited: Walter Roberson on 7 Dec 2015
Thanks Walter, I want code over the image. I rewrite code according to your tip.
Pro=regionprops(Lb,'Area','Centroid');
figure,imshow(Original),
for cnt = 2:length(Pro)
text(Pro(cnt).Centroid(1),Pro(cnt).Centroid(2),num2str(Pro(cnt).Area*0.07*0.07),'FontSize',5,'color','red');
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!