How do I convert a 4D image to a scalar one?
2 views (last 30 days)
Show older comments
I have a 4D stack of images and need to convert it to scalar so I can multiply every each individual slice with a vector. Any idea?
4 Comments
Image Analyst
on 7 Jul 2018
What does that mean, to multiply a slice "to a vector"? I have no idea. Do you have a translation matrix for every slice of a stack of color images? So each color image gets moved by a different amount and direction? Or do you just want to multiply the value by a scalar? For that matter, what does "slice" mean in a 4-D context? A "slice" of a 4-D matrix is a 3-D matrix, which could be a color image. Or it could be a volumetric or some other interpretation of a 3-D "slice" of the 4-D matrix. For any dimension, a slice is usually thought of as being one less dimension than the original. A slice of a 3D image is a 2D image. A slice of a 4-D image is a 3-D image. A slice of a 15 dimension matrix is a 14 dimension array. Etc.
Answers (1)
Image Analyst
on 8 Jul 2018
Try this:
imSize = size(im);
for k = 1 : imSize(4)
% Extract one 3-D image from the 4-D image.
thisImage3D = im(:, :, :, k);
% Now determine translation parameters somehow
translationParameters = GetTransform(thisImage3D); % You write this...
% Now apply those paramters to this 3-D image we extracted.
% Again you write this function.
transformedImage3D = ApplyTransform(thisImage3D, translationParameters);
% Stick it back in im
im(:,:,:,k) = transformedImage3D;
end
Don't ask me how to "derive from a translation matrix" because I have no idea how you plan on getting that matrix. Presumably you know how to do that already.
4 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!