How do you get regionprops "images" (e.g. FilledImage, Image, ConvexImage) to be the same size as the original image?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Image Analyst
el 16 de Jul. de 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.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!