[ITK] Best way to convert 4D image to 3D in-place?

Bradley Lowekamp blowekamp at mail.nih.gov
Wed May 7 08:16:37 EDT 2014


Hello Chris,

You are right this is a feature that could/should be added to the ExtractImageFilter. Another place is the CastImageFilter too as that supports conversion of dimensions of images. Looking thought the Code it looks like the InPlaceImageFilter, the UnaryFunctorImageFilter  and the ExtractImageFilter would need to be updated. It's be a little tricky to support too. But it's correct that the buffer is the same for this case.

What may be an easier path would be to run the Extract filter in 4D->4D mode, with the InPlace option. At this point the buffer should be correct. You could write a filter which does the 4D->3D in-place which just checks the preconditions for being able to run in-place for this case and then grafts the buffered regions.

What are the unpleasant assumption you are making?

Brad


On May 6, 2014, at 7:15 PM, Chris Cooper <chris.cooper at veranmedical.com> wrote:

> I’ve got a 4-dimensional image (itk::Image<short,4>) and I need to extract the first “slice" of that image into a 3-dimensional image (itk::Image<short,3>) .
> 
> I can do it with an ExtractImageFilter, but since my input and output images don’t match, the filter insists on allocating new memory for the new image, and that’s not going to fly.
> 
> I can do it with an ImportImageFilter by passing the buffer pointer of the 4-d image to the filter, and that works fine, but (1) it makes assumptions about the layout of the image in memory that I would rather not make, and (2) it requires me to Update() my 4-d image manually prior to continuing the filter pipeline which while not a problem, is not as “clean” as I would like.
> 
> Is there a filter that would let me extract the image I need, without making unpleasant assumptions and certainly without allocating more memory?
> 
> Thanks,
> Chris
> 
> 
> 
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140507/473cca6d/attachment-0002.html>


More information about the Community mailing list