How do I convert a 4D image to a scalar one?
조회 수: 1 (최근 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.
댓글 수: 4
참고 항목
카테고리
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!