How can i convert a 3D image to 2D in matlab?
91 次查看(过去 30 天)
显示 更早的评论
I am using a code that will work only on 2D arrays and I have to convert the current image which is in 3D to 2D.
0 个评论
回答(2 个)
Image Analyst
2012-2-20
编辑:Image Analyst
2014-2-28
If the 3D image is a color image, you can take individual color channels like this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Or you could use a weighted average of the red, green, and blue channels like this:
grayImage = rgb2gray(rgbImage);
Or if you have a volumetric image (like a CT or MRI image or other image distributed in 3 spatial dimensions) you can use the mean (or max or min) like this
xyImage = mean(volumeImage, 3);
xzImage = mean(volumeImage, 2);
yzImage = mean(volumeImage, 1);
They will get you the average of the 3D volumetric image projected along one of the dimensions.
7 个评论
Mihirasree
2022-11-9
thank you soo much sir your suggestions helping us all a lot . Thanks for helping us
Dinesh kumar
2016-11-13
please answer me the coding for how to convert a 3d image into 2d image
4 个评论
Walter Roberson
2017-1-24
https://www.mathworks.com/matlabcentral/answers/122486-how-can-i-load-and-view-medical-image-mha to read it. You can then extract slices of the result using array indexing.
Galiyabi P S
2017-1-29
Thanks Walter Roberson for your answer. It helps me to read and display the mha image. Can you help me to convert these images to rgb format?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!