How do I convert a 4D image to a scalar one?

조회 수: 1 (최근 30일)
Stelios Fanourakis
Stelios Fanourakis 2018년 7월 7일
댓글: Stelios Fanourakis 2018년 7월 15일
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
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.
Stelios Fanourakis
Stelios Fanourakis 2018년 7월 7일
Slices of 15 images result to a 4D stack of images im(:,:,:,:). I need to translate every one of those 15 slices to different positions that derive from a translation matrix. How do I do that?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
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
Stelios Fanourakis
Stelios Fanourakis 2018년 7월 15일
I have another assumption. im2 is a 4D interpolated stack of images (stack out of 15 images) using interp3.
Interpolation to me, means that it creates in between images. For example, if there is 1 to 2 image, the interpolation will give us 1.5 image. Am I correct? So that's what interp3 does. It increases the number of images above 15, where they really are.
Then, by importing im2 to GriddedInterpolant, again another interpolation takes place, so even more subimages are created. Thus, the total number of slices that consist the stack may exceed 30, but, definitely it won't be 15 where it started.
Then, with GridVectors I turn it to cell array and by multiplying with the translation_vector, supposedly they are shifted. BUT, the translation_vector matrix is consisted out of 15 rows and 2 columns. 15 rows as the original images NOT the interpolated ones. So, a lot of images do not shift.
Am I right to my assumption. Is this more clear so we can find a solution?
Stelios Fanourakis
Stelios Fanourakis 2018년 7월 15일
@Matt. I though of another solution. When I use result = F(g) I apply interpolation again to g which are the original set points (image) multiplied by translation_vector.
That means that the original image has already been shifted plus a new interpolation coming on the way (F(g)). Does it make it somehow to be smushed or squeezed?
If I visualize with only g without F(g) I get errors later on to the uicontrol of the slider (e.g. Index Exceeds Matrix Dimensions).
Would it be correct to visualize only with g?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by