3D image from 10rgb slices

4 views (last 30 days)
Sermed
Sermed on 25 Jan 2013
Hi I have 10 rgb images (100x 100x 3) and want to combine them into a single 3D image. Is it possible ? thanks in advance Sermed
  1 Comment
Image Analyst
Image Analyst on 26 Jan 2013
So which of the two methods below is what you want?

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 25 Jan 2013
How do you want to combine them? Do you want a single x00x100x3 image that is the average of all of them? If so, cast them to double and add them, then cast back to uint8 (if that's how they started).
aveImage = uint8((double(image1) + double(image2) + ... + double(image10))/10);

Thorsten
Thorsten on 25 Jan 2013
Because RGB is already 3D, you can combine them in the fourth dimension
I1 = ones(10, 10, 3);
I2 = 2*ones(10, 10, 3);
All(:,:,:,1) = I1;
All(:,:,:,2) = I2;
or you can stack them one after the other in the third dimension:
All(:,:,1:3) = I1;
All(:,:,4:6) = I2;
or you can use cells
All{1} = I1;
All{2} = I2;

Youssef  Khmou
Youssef Khmou on 27 Jan 2013
Hi, here is an other viewpoint that combines the two given answers : you create an Image_Stack and then do what you prefer like median, mean ... :
Stack=zeros(100,100,3,10);
% ur first image I1
Stack(:,:,:,1)=im2double(I1);
%..and so on until 10
Stack(:,:,:,10)=im2double(I10);
Sum=zeros(100,100,3);
for iter=1:10
Sum=Sum+Stack(:,:,:,iter);
end Combined=Sum/10;
I hope that helps .
KH.Youssef

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!