How to convert 2D images to 1 3D image
11 views (last 30 days)
Show older comments
I have about 170 2D image slices of a brain. These are all saved in a .tif file. I want to take all these slices and put them all together to form a 3D image of the brain. I'm not sure where to even start, can anyone help?
Thanks
Update: This is what I have tried so far
FileTif='C:\Users\Taylor\Desktop\P_TH1_S_2237_29-Nov-2016_13.52.30_OCT.tif';
InfoImage=imfinfo(FileTif);
mImage=InfoImage(1).Width;
nImage=InfoImage(1).Height;
NumberImages=length(InfoImage);
FinalImage=zeros(nImage,mImage,NumberImages,'uint16');
for i=1:NumberImages
FinalImage(:,:,i)=imread(FileTif,'Index',i);
end
imshow(FinalImage)
Here are the errors I receive:
Error using images.internal.imageDisplayValidateParams>validateCData (line 115)
Multi-plane image inputs must be RGB images of size MxNx3.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 222)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in SignalsProject2 (line 18)
7 Comments
zahra ghadery
on 30 Aug 2021
hello
i have the same problem. Did you solve it? Would you please help me?
Image Analyst
on 30 Aug 2021
@zahra ghadery if your images are color, then you'll have to convert them to gray scale to use this:
grayImage = imread(FileTif, 'Index', i);
FinalImage(:, :, i) = grayImage; % Gray scale
Otherwise you can try inserting the color image into a 4-D matrix:
FinalImage(:, : , :, i) = imread(FileTif, 'Index', i); % Color
Answers (2)
Image Analyst
on 30 Nov 2016
MATLAB's 3-D volume visualization capabilities are pretty primitive. They're pretty much limited to cutaway views (slices) and isosurfaces, as you can see from Adam's links. If you need anything more advanced you'll have to use a program like Avizo: https://www.fei.com/software/avizo-3d/ which can do virtually anything you can possibly think of.
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!