Creating lung volume from CAT scan?

It's going to work amazing in that imageset, but when i try to use mine, i dont know what should i do?
I'm working with DICOM format but also i can work with the jpeg format, if its going to be problem.
This is the code from i get the link but im not sure how to change this for my imageset(link)
Edit: I solved the importing issue, now i can use my own imageset. But now i have another issue on Image Segmentation.
Im going to use this segmentation on volume segmentation as a slice mask.
I thresolded, inverted and cleaned borders and filled holes. But still the base of tomography showing here. Any possibilities to using that mask in that red rectangle region?
And any possibilities have we to export this into a 3D object?
[V,spatial,dim] = dicomreadVolume(fullfile("Seri2"));
V = squeeze(V);
whos V
V = im2single(V);
XY = V(:,:,180);
XZ = squeeze(V(256,:,:));
figure
imshow(XY,[],'Border','tight');
figure
imshow(XZ,[],'Border','tight');
%%
BW = XY > 7.647100e-01;
BW = imcomplement(BW);
BW = imclearborder(BW);
BW = imfill(BW, 'holes');
radius = 3;
decomposition = 0;
se = strel('disk',radius,decomposition);
BW = imerode(BW, se);
maskedImageXY = XY;
maskedImageXY(~BW) = 0;
imshow(maskedImageXY)
%%
BW = XZ > 7.647100e-01;
BW = imcomplement(BW);
BW = imclearborder(BW);
BW = imfill(BW, 'holes');
radius = 3;
decomposition = 0;
se = strel('disk',radius,decomposition);
BW = imerode(BW, se);
maskedImageXZ = XZ;
maskedImageXZ(~BW) = 0;
imshow(maskedImageXZ)
%%
mask = false(size(V));
mask(:,:,160) = maskedImageXY;
mask(256,:,:) = mask(256,:,:)|reshape(maskedImageXZ,[1,512,212]);
V = histeq(V);
%%
BW = activecontour(V,mask,100,'Chan-Vese');
segmentedImage = V.*single(BW);
volumeViewer(segmentedImage)
%%
volLungsPixels = regionprops3(logical(BW),'volume');
spacingx = 0.938;
spacingy = 0.938;
spacingz = 1.26*le-6;
unitvol = spacingx*spacingy*spacingz;
volLungs1 = volLungsPixels.Volume(1)*unitvol;
volLungs2 = volLungsPixels.Volume(2)*unitvol;
volLungsLiters = volLungs1 + volLungs2
%%

 Accepted Answer

If you have row1, row2, col1, and col2 of your red box, then you can erase the 2-D binary image outside that like this:
mask(1:row1, :) = false;
mask(row2:end, :) = false;
mask(:, 1:col1) = false;
mask(:, col2:end) = false;

4 Comments

Mr. Image Analyst im really sorry to disturb you, but im stuck again.
[128:132]
[400:132]
[128:315]
[400:315]
These are the 4 corners of the red rectangle on pixel region, im making the rows and cols like this but im giving error. What should i do?
row1 = maskedImageXY((128:132),(400:132));
row2 = maskedImageXY((128:315),(400:315));
col1 = maskedImageXY((128:132),(128:315));
col2 = maskedImageXY((400:132),(400:315));
mask = false(size(V));
mask(:,:,160) = maskedImageXY;
mask(256,:,:) = mask(256,:,:)|reshape(maskedImageXZ,[1,512,212]);
mask(1:row1, :) = false;
mask(row2:end, :) = false;
mask(:, 1:col1) = false;
mask(:, col2:end) = false;
V = histeq(V);
row1, etc. are single numbers, not images. So
row1 = 128
row2 = 400
col1 = 132
col2 = 315
Works like a charm! Thank you so much! I think it is not possible but, could have any chance to exporting this volume as .stl or .obj format?
I don't use those formats, so I don't know. You'll have to figure it out on your own. If my main answer worked, could you please "Accept this Answer". Thanks in advance.

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Community Treasure Hunt

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

Start Hunting!