Open jianghaizhu opened 8 years ago
Would it work to call copy
on your input matrix before passing it to interpolate!
?
Yes, I can make a copy of the input matrix before interpolate!
, which would allocate the same amount of memory as interpolate
. However, since I have tens of thousands of volumes whose size are fixed, I can pre-allocate a volume with the right size and use copy!()
to copy the input matrix to the pre-allocated volume before interpolate!
to limit the memory allocation, which is an improvement. But that is still tens of thousands additional copies of large 3d matrices, e.g. 250x250x250.
Can you get away with Linear
? The reason I ask is that Linear
does not require prefiltering; if you don't need to do prefiltering, then it does not destroy the input.
If you do need Quadratic, and can use InPlace
, then you can copy to a reusable buffer as you say. I don't think there's an alternative to copying if you want to use the current infrastructure: interpolate!
uses the input to store the interpolation coefficients, and those are not equal to the input data for anything higher than Linear
.
Thanks! I did find out that when using Linear
the output was not destroyed and was puzzled. Now I know why. Yes, right now I can go with Linear
, but eventually I need to move to Quadratic
and even Cubic
. I didn't find an InPlace
for Cubic
though. Will this be implemented? Also when using BSpline(Quadratic(InPlace()))
, the GT has to be OnCell()
?
Somebody probably needs to work out the mathematics. If you're interested in tackling that, there was once some PDF documentation on InPlace
but it seems to have been removed. Perhaps you could try checking out older versions of this package to find it.
I am using AffineTransform to transform a large number of volumes and the interpolation process allocated a huge amount of memory. I know there is a
interpolate!
function. Howeverinterpolate!
would destroy the input matrix. Also it looks like it can only be used withBSpline(Quadratic(InPlace()))
. Is there a way to output the interpolation to a pre-allocated matrix but also keep the input matrix? Thanks!