How to achieve a faster 3D Translation?
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm making a GUI to allow a user to do image translation on set of 3D image data.
I want the user to be able to visually see the effects of the shift (using XY, XZ, and YZ slices).
I've tried this for 3D:
% 3D transform:
trslt = [eye(3) xyz'; 0 0 0 1]';
tform = maketform('affine', trslt);
data = tformarray(data, tform, rsmp, [2 1 3], [2 1 3], sizXYZ([2 1 3]), [], 0);
However, performing the following 2D operations runs in a fraction of the time:
xyTform = maketform('projective',[1 1; 1 sizY; sizX 1; sizX sizY],[1+x 1+y; 1+x sizY+y; sizX+x 1+y; sizX+x sizY+y]);
zTform = maketform('projective',[1 1; 1 sizY; sizZ 1; sizZ sizY],[1+z 1; 1+z sizY; sizZ+z 1; sizZ+z sizY]);
data = tformarray(data, zTform, rsmp, [3 1], [3 1], sizXYZ([3 1]), [], 0);
data = tformarray(data, xyTform, rsmp, [2 1], [2 1], sizXYZ([2 1]), [], 0);
Is there any better (or faster) way to do this?
Edit: Just to clarify, I'm using this transform to allow shifting by "fractional" pixel amounts. I know this would be easier if shifting by whole pixels.
댓글 수: 0
채택된 답변
Sean de Wolski
2013년 1월 28일
You may be able to get better speeds with griddedInterpolant(), especially if you have to do this multiple times at the same query points.
댓글 수: 3
Sean de Wolski
2013년 1월 28일
I don't believe so in R2012b. However, the R2013a Prerelease, available to customers with an SMS subscription, might interest you.
Also note, that on the image edges, you are no longer interpolating but extrapolating. You may wish to prepad your image before doing the transformation.
I never did ask, how long is tformarray() actually taking and how big are your images?
For a 1000x1000x5 it's taking only 1.5-2s on my machine:
A = rand(1000,1000,5);
tic
A2 = imtranslate(A,[1.48 pi -2.3]);
toc
추가 답변 (1개)
vishal
2015년 6월 5일
hello christopher, how did you read dicom image? is there any direct command to get matrix size like 377*377*127 ? or you resized the image to get 3d array?? like the given code??? fid = fopen('1.im','r'); %got to the first byte after the header status = fseek(fid,1024,'bof'); %read the data data = fread(fid); %close the file fclose(fid); %reshape the data into a 3D array data3d = reshape(data,128,128,128);
댓글 수: 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!