How do you get regionprops "images" (e.g. FilledImage, Image, ConvexImage) to be the same size as the original image?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a label matrix. I am using regionprops to measure properties for each labeled region. Some of those properties are images (e.g. FilledImage, Image, ConvexImage), but they are always the size of the bounding box of the region. How can I convert this to the size of the original image?
Example
Suppose
L = [2 2 0 0 0 0;
2 2 0 1 1 0;
0 0 0 0 1 0;
0 0 1 1 1 0];
stats = regionprops(L,'all');
Then
stats(1).ConvexImage = [0 1 1;
0 1 1;
1 1 1];
But what I want is
[0 0 0 0 0 0;
0 0 0 1 1 0;
0 0 0 1 1 0;
0 0 1 1 1 0];
How can I achieve this?
I'm sure it can be done by using the BoundingBox, but for some reason, I cannot recall how to do this.
Akzeptierte Antwort
Image Analyst
am 16 Jul. 2013
I can think of a way, but not an easy way - uses BoundingBox like you said. Fortunately there is an easy way for some returned images like the filled regions and the convex regions, but it doesn't use regionprops. For filled regions, use imfill(). For the convex regions, use bwconvhull() (in later versions of the Image Processing Toolbox). If there is some other thing you want, other than those two, let me know.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!