How does one rescale an array of 3D images in MATLAB R2011b?
조회 수: 1 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2013년 1월 25일
편집: MathWorks Support Team
2016년 8월 1일
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
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!