フィルターのクリア

How to achieve a faster 3D Translation?

1 回表示 (過去 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 Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by