필터 지우기
필터 지우기

How does one rescale an array of 3D images in MATLAB R2011b?

조회 수: 2 (최근 30일)
I'm trying to rescale a 512 x 512 x 56 3-d image array which has physical dimensions of 0.07 cm in the x and y directions and 0.13 in the z direction, so that the physical dimensions in each direction are the same. I can't figure out the way to do it. I was thinking of the "maketform" command with the 'box' option, but I can't find an example of how to specify the arguments with this option. Do you have any suggestions?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2016년 8월 1일
This can be done in 2 ways:
1) Using a combination of MAKETFORM, MAKERESAMPLER and TFORMARRAY.
Please refer to the documentation for TFORMARRAY for for information:
<http://www.mathworks.com/help/images/ref/tformarray.html>
2) You can also do this using the INTERP3 or GRIDDEDINTERPOLANT functions. These are effectively the same under the hood.
Please refer to the following documentation for more information of GRIDDEDINTERPOLANT:
<http://www.mathworks.com/help/matlab/ref/griddedinterpolantclass.html>
the following code demonstrates this:
%%Creates a 3D image
A = imread('eight.tif');
for j=1:10
A(:,:,1+j)=A(:,:,1)-20*j;
end
RFactor=2;
%%Using TFORMARRAY
T=maketform('affine',[RFactor 0 0 0; 0 RFactor 0 0; 0 0 RFactor 0; 0 0 0 1]);
R = makeresampler('cubic', 'bound');
TSIZ_IN=size(A);
TSIZ_OUT=ceil(TSIZ_IN.*RFactor);
OUTIMG=tformarray(A,T,R,[1 2 3],[1 2 3],TSIZ_OUT,[],[]);
%%Using INTERP3
[sy sx sz]=size(A);
[X,Y,Z]=meshgrid(1:sx,1:sy,1:sz);
[X2,Y2,Z2]=meshgrid(1:1/RFactor:sx,1:1/RFactor:sy,1:1/RFactor:sz);
OUTIMG2=interp3(X,Y,Z,single(A),X2,Y2,Z2,'Cubic');
OUTIMG2=uint8(OUTIMG2);

추가 답변 (0개)

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by