필터 지우기
필터 지우기

How to achieve a faster 3D Translation?

조회 수: 3 (최근 30일)
Christopher
Christopher 2013년 1월 28일
답변: vishal 2015년 6월 5일
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.

채택된 답변

Sean de Wolski
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
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
Christopher
Christopher 2013년 1월 28일
편집: Christopher 2013년 1월 28일
I'm using DICOM image data from a PET/MR scan. Matrix size is 377x377x127
It takes ~8 seconds on my machine for two 2D transforms and ~20 seconds for a 3D transform.
It's only taking ~2-3 seconds to use griddedInterpolant().
I may try the R2013a Prerelease.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

vishal
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);

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by