Use 2D ROI slices to create 3D surface?

33 views (last 30 days)
I have 15 MR image slices of my heart (left-ventricle) that I have contoured using drawfreehand. I would like to line them up as they would be in my body, and then create a surface model of the ventricle. I've already experimented with several ways of doing this:
I tried to plot them all as polygons with fill3, which looks good, but I want to connect these contours together:
I've also tried reorganizing the data and plotting it as lines using plot3:
It makes a 'groovy' picture, but also not what I wanted. I have also of course tried surf:
but, I keep getting this garbage. I can see why I'm getting that, but I would like help getting something that looks more like a left ventricle (kind of a cone/volcano looking shape). I tried using meshgrid, but I'm not very good at 3D plotting, so I could just be doing something wrong. I've also tried triangulation and a 3d surface fit, which both gave me a mess and connected points from opposite sides of the volume. Can anyone help me get on the right track?

Accepted Answer

Suvansh Arora
Suvansh Arora on 9 Nov 2022
One way to do this is the following example. However instead of using ‘imread’ with ‘me.jpg’, the data can be used.
I = imread('me.jpg'); % load in image
imshow(I)
% Figure 1 is the original image
f = figure
level = graythresh(I);
BW = im2bw(I,level);
imshow(BW)
% Figure 2 is the threshold image
% Create the stacked image by stacking the binary image repeatedly
f = figure;
binaryFile = []
for i = 1:200
binaryFile(:,:,i) = BW;
end
% Sample the binary file
binaryFile = binaryFile(1:5:end, 1:5:end, 1:5:end)
% Smooth the image
binaryFile = smooth3(binaryFile);
[x,y,z] = meshgrid(1:size(binaryFile,2),1:size(binaryFile,1),1:size(binaryFile,3));
[faces,verts] = isosurface(x,y,z,binaryFile,0.5);
% Creates a surface between 1's and 0's.
p = patch('Vertices', verts, 'Faces', faces, ...
'FaceColor','interp', ...
'edgecolor', 'interp');
% Remove the color
p.FaceColor = 'none';
% Leave color on the edges
p.EdgeColor = 'red';
% Figure 3 is figure 2 stacked repeatedly
colormap jet
axis equal
view(3)
Kindly go through the following links for reference:
  1 Comment
Alexander Moody
Alexander Moody on 15 Nov 2022
Thank you! This is a thorough answer, and it's much appreciated.

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!