[Insight-users] itk filters and memory use
devieill at irit.fr
devieill at irit.fr
Tue Sep 21 07:45:21 EDT 2010
Hi all, (sorry for duplicates)
still on benching my progs on a 4g ram 2 core laptop, I face an ugly issue
: code with iterators (thus not threaded) goes much faster than a code
done with the filters, of course this happens for "large" 3D images
(starting from 380^3 voxels).
So my questions are :
- are filters designed to save memory ?
- is it better to process data on each filter separately ( thus no chain
with connected input/output) from a memory point of view ?
To better explain my purpose, I want to compute the gradient of the Total
Variation in dimension 3 using the "beta" trick to ensure stability.
basically it look likes, given an image src:
compute
l2norm_beta = sqrt( dx(src)^2+dy(src)^2+dy(src)^2 +beta)
grad = dx(dx(src)/l2norm_beta) + dy(dy(src)/l2norm_beta) +
dz(dz(src)/l2norm_beta)
return grad
As you can imagine lots of filter need to be connect in order to fit this
computation, and sadly a simple iterator based computation works better
for large image on my 4gig computer.
In fact it is not clear to me whether this should be valid :
typedef itk::SquareImageFilter< WorkingImageType, WorkingImageType >
SquareFilter;
SquareFilter::Pointer sqrt_op = SquareFilter::New();
sqrt_op->SetInput(src);
src = sqrt_op->GetOutput();
src->Update();
As far as I understand it, the filters will use iterators, so assuming the
things are done properly (and not on all possible filters btw) the "Set"
operation comes after the "Get" one, so this should not mess-up the
computation and prevent some useless memory allocation.
So in anyway, if there is a way to use the connecting itk pipeline without
overusing the memory (and to avoid swapping...) I would be glad to hear
it.
Regards,
de Vieilleville François
More information about the Insight-users
mailing list