Increase speed of imwarp

17 次查看(过去 30 天)
Jaime
Jaime 2014-3-7
Dear Matlab community
I have been using imwarp to spatially transform CT-images along with an upscaling step. I would like to optimize my code and I've found that imwarp is taking a lot of time for my needs. Since I need to upscale one of the images by about 2x2x3 in the x,y, and z direction, respectively, the function ends up taking around 10 minutes per image. After doing a profile check it is actually interp3 the one function inside imwarp that consumes most of the time. I wonder if there are ways to speed imwarp like using parallel computing or other alternatives.
Best regards, Jaime
  1 个评论
Igor Reidler
Igor Reidler 2015-8-23
Hi Jaime, I'm facing a similar situation. Was wondering if you had any progress using parallel computing toolbox, GPU computing, or other?
Thanks, Igor.

请先登录,再进行评论。

回答(2 个)

Matt J
Matt J 2015-8-23
IMWARP seems like the wrong tool for upsampling images. griddedInterpolant is probably smarter, in the sense that it knows that the upsampling can be done separably, and hence more efficiently:
[m,n,p]=size(CTVolume);
gridVectors={linspace(1,m,2*m),...
linspace(1,n,2*n),...
linspace(1,p,3*p)};
F=griddedInterpolant(CTVolume);
newImage=F(gridVectors);

Kees de Kapper
Kees de Kapper 2018-3-21
Dear all,
I know this thread is a bit "old" but I've got a similar question. I'm using imwarp for extracting a 2D image from a 3D dataset but with the use of a 3D transformation.
What I experienced is that the speed of imwarp does not depend on the size of the resample output but on the size of the input image. This surprised me a lot and implies a very inefficient implementation.
I found by searching the web, the function tformarray that I might use as well. Using this function the calculation time is reduced with a factor more than ten. I find this very surprising as I expect the imwarp function is build on top of the tformarray-function (correct me if I'm wrong). Do I make a mistake?
The disadvantage is that when using tformarray, I have to construct a tmap_B that reflects the pixel index corresponding to the axis coordinates for both input and resample axis. Although this might be trivial, is there a in-build Matlab function that can do the job?
I'm looking forward to your comments.
Many thanks in advance,
Kees

标签

Community Treasure Hunt

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

Start Hunting!

Translated by