Convert a cell array containing binary images to a 3D array and build 3D volume from the 3D array
Afficher commentaires plus anciens
I have 20 DICOM images, from these images I have extracted region of interest using Activecontour function. The extracted ROI of all 20 images(binary images) are stored in a cell array and I need to stack these images to build a 3D volume.
clc
close all
imtool close all
%%Read N images
% Read images
[filename, pathname, filterindex] = uigetfile( ...
{ '*.dcm','DICOM IMages (*.dcm)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file', ...
'MultiSelect', 'on');
% Get number of images
files_length = length(filename);
% figure,montage(filename,'displayRange',[]);
for q = 1:files_length
I = dicomread(filename{q});
if q == 1
imshow(I,[]);
[x,y]=(ginput(1));
mask = zeros(size(I));
mask(y-50:y+50,x-50:x+50)=1;
end
% Region growing using acclc
seg = activecontour(I,mask,'chan-vese');
seg_gray{q} = ind2rgb(seg, lines(20));
end
save('newmatFile.mat','seg_gray');
%%Reconstruction:
load newmatFile
seg_gray = squeeze(seg_gray);
[a,b,z,seg_gray] = subvolume(seg_gray,[nan,nan,nan,nan,nan,nan]);
p1 = patch(isosurface(a,b,z,seg_gray, 5),...
'FaceColor','red','EdgeColor','none');
isonormals(a,b,z,seg_gray,p1);
p2 = patch(isocaps(a,b,z,seg_gray, 5),...
'FaceColor','interp','EdgeColor','none');
view(3); axis tight; daspect([1,1,.4])
colormap(gray(100))
camlight right; camlight left; lighting gouraud
2 commentaires
Amith Kamath
le 10 Juin 2015
Nitin: I see that you've submitted another related question here http://www.mathworks.com/matlabcentral/answers/221954-build-a-3d-volume-using-using-processed-roi-extracted-slices-but-i-am-unable-to-do-it-can-anybody, and you mention that you encounter an error. It would be nice if you could share the error message you see as well. Also, from a quick glance through your code here, it seems like you are creating a cell array
seg_gray
Is there a particular reason why this is a cell array? Why not create a 3D matrix, like
seg_gray(:,:,q)
?
NITIN V P
le 24 Juin 2015
Réponses (1)
Image Analyst
le 21 Juin 2015
Don't use a cell array. Get the gray image by masking then insert into a 3D array
seg_gray(:, :, q) = uint8(seg) .* I;
3 commentaires
NITIN V P
le 24 Juin 2015
Image Analyst
le 24 Juin 2015
Nitin V P's "Answer" moved here:
Convert all the extracted images to same class(int)
seg{q} = im2int16(seg1);
Image Analyst
le 24 Juin 2015
I and seg have to be the same type of integer. Cast one of them to match the other and it should be okay. Maybe you have to use uint16 instead of uint8.
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!