How do you get regionprops "images" (e.g. FilledImage, Image, ConvexImage) to be the same size as the original image?
6 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
Image Analyst
2013-7-16
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!