View the segmented object and corresponding 3D bounding box together
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vinit Nagda
le 24 Mai 2021
Commenté : Vinit Nagda
le 28 Mai 2021
I have a labelled volumetric matrix data and I can view the segmented objects in volumetric data in the VolumeViewer App. Then, using 'regionprops3' function, I get the 'BoundingBox' property of each object. How can I view the object and its corresponding bounding box together?
0 commentaires
Réponse acceptée
Uday Pradhan
le 28 Mai 2021
Modifié(e) : Uday Pradhan
le 28 Mai 2021
Hi Vinit,
You could use the drawcuboid function to construct your cuboidal bounding box around a volume. I am attaching an example script below, I hope it will help you get started:
%% Script taken from : https://nl.mathworks.com/help/matlab/visualize/visualizing-volume-data.html
load mri D % load data
D = squeeze(D); % remove singleton dimension
limits = [NaN NaN NaN NaN NaN 10];
[x, y, z, D] = subvolume(D, limits); % extract a subset of the volume data
[fo,vo] = isosurface(x,y,z,D,5); % isosurface for the outside of the volume
[fe,ve,ce] = isocaps(x,y,z,D,5); % isocaps for the end caps of the volume
f = figure
hold on;
p1 = patch('Faces', fo, 'Vertices', vo); % draw the outside of the volume
p1.FaceColor = 'red';
p1.EdgeColor = 'none';
p2 = patch('Faces', fe, 'Vertices', ve, ... % draw the end caps of the volume
'FaceVertexCData', ce);
p2.FaceColor = 'interp';
p2.EdgeColor = 'none';
view(-40,24)
daspect([1 1 0.3]) % set the axes aspect ratio
colormap(gray(100))
box on
camlight(40,40) % create two lights
camlight(-20,-10)
lighting gouraud
roi = drawcuboid(gca,'Position',[15 15 0 95 120 10],'InteractionsAllowed','none');
%Turn InteractionsAllowed to all if you want to manually adjust size of the
%box
Result:
Please check the Position argument accepts the cuboid information in the form of a 1 by 6 vector defined as [xmin ymin zmin w h d] where (xmin ymin zmin) is the lower left vertex of the cuboid. So you need to be careful about the 1 by 6 bounding box information given by regionprops3 as they might not be what drawcuboid expects. Note: regionprops3 returns Smallest cuboid containing the region, returned as a 1-by-6 vector of the form [ulf_x ulf_y ulf_z width_x width_y width_z]. ulf_x, ulf_y, and ulf_z specify the upper-left front corner of the cuboid. width_x, width_y, and width_z specify the width of the cuboid along each dimension.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!