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!