Convert a cell array containing binary images to a 3D array and build 3D volume from the 3D array
이전 댓글 표시
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
Amith Kamath
2015년 6월 10일
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
2015년 6월 24일
답변 (1개)
Image Analyst
2015년 6월 21일
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
NITIN V P
2015년 6월 24일
Image Analyst
2015년 6월 24일
Nitin V P's "Answer" moved here:
Convert all the extracted images to same class(int)
seg{q} = im2int16(seg1);
Image Analyst
2015년 6월 24일
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.
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!