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!