How to construct 3D images from 2D images taken at different depth of that object?
3 次查看(过去 30 天)
显示 更早的评论
I have the 2D images of brain taken at different depth.
First of all,Every 2D images have a thickness.
1.How can I construct 3D images/higher Dimensions images from those 2D images? I have no idea how to do that. Anyone can point the direction for me? Is it the case like reconstruction of CT slice?
2. I am using the following code to read those file in tif formal and and after that I got a file for those image. How can I show that file? Imshow don't support that.
filebase = 'C:\Users\user\Desktop\matlab'; startFrame = 1; endFrame = 19; %read frames, reduce size, show frames, and build volume for i=startFrame:endFrame filename=[filebase, num2str(i,'%2d'),'.tif'] temp=double(imresize(imread(filename), 0.5)); slice(:,:,i) = (temp(:,:,1)==255) + 2*(temp(:,:,2)==255) + 4*(temp(:,:,3)==255); imagesc(slice(:,:,i)); colormap('gray') drawnow end
My english is not very good. Maybe there is something that is not very clear to you. Please ask me If you cannot understand some parts. Thank you
John
0 个评论
采纳的回答
Aurele Turnes
2014-8-6
Looking at the code you provided, it is not clear what this line is trying to achieve:
slice(:,:,i) = (temp(:,:,1)==255) + 2*(temp(:,:,2)==255) + 4*(temp(:,:,3)==255);
However, if your goal is to convert a color image to grayscale (thus eliminating the third dimension of your image data), you can achieve this using the rbg2gray function as follows:
slice(:,:,i) = rgb2gray(temp);
You can then view your image using the imagesc function.
In order to view a 3D representation of your data (as a volume), you can use the isosurface function and try different values for the isovalue input.
There is also a file exchange submission called sliceomatic that can allow you to visualize your 3D data and help you select the isosurface and slices in different dimensions.
You can try running the example below and see if this works for you (note that I renamed the variable slice to myslice because it shadows a native MATLAB function. Also, I added a few lines to initialize the variable myslice with the appropriate dimensions):
filebase = 'C:\Users\user\Desktop\matlab';
startFrame = 1;
endFrame = 26;
% Initialize slice below. If you know the sizes M and N in advance, you can
% skip the following two lines
filename=[filebase, num2str(1,'%2d'),'.tif'] ;
temp=double(imresize(imread(filename), 0.5));
[M,N] = size(temp(:,:,1));
myslice = zeros(M,N,endFrame-startFrame+1);
for i=startFrame:endFrame
filename=[filebase, num2str(i,'%2d'),'.tif'] ;
temp=double(imresize(imread(filename), 0.5));
% convert to gray scale
myslice(:,:,i) = rgb2gray(temp);
imagesc(myslice(:,:,i));
colormap('gray')
drawnow
end
% try isosurface with isovalue = 0.5
figure
isosurface(myslice,0.5)
% % Uncomment to try the sliceomatic function
% figure;
% sliceomatic(myslice)
1 个评论
Rafid Mustafiz
2016-12-8
when I run your code the following error appear ---- plz help me #Aurele Turnes
Error using rgb2gray>parse_inputs (line 82) MAP must be a m x 3 array.
Error in rgb2gray (line 37) X = parse_inputs(X);
Error in reconstruction_3D (line 18) myslice(:,:,i) = rgb2gray(temp);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!