How do I convert a 4D image to a scalar one?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2018-7-7
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.
回答(1 个)
Image Analyst
2018-7-8
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!