[ITK-users] Splitting and repasting a volume with overlap

Pol Monsó Purtí lluna.nova at gmail.com
Tue Mar 17 13:13:02 EDT 2015


Hello Matt,

As I've told Bradley, I can't use streaming as-is because I need overlap
between chunks and because the low-level library would need a proper itk
image with correct size, region, etc.
which I guess it wouldn't be provided by streaming.

But most definetely, right now I use 'streaming' by using the ExtractFilter
at the end. I believe that streams too. I was actually more interested in
having a filter/object that computes the splits for me. I've implemented
it, but it's far from perfect. For example, it broke when the input image
had a non-zero index. (It's fixed now, but still, I'm sure the itk's
Splitter filter does a better job, if only could I have overlap ;))

I guess the way to go would be to take the splitter (probably
ImageRegionSplitterMultidimensional now that I look at it) and extend it to
support overlap. If I do it, I'll let you know in case it is of interest to
anyone. For now I'll stick to my class.

Cheers,

Pol

2015-03-16 16:05 GMT+01:00 Matt McCormick <matt.mccormick at kitware.com>:

> Hi Pol,
>
> As a side note, limitation of memory usage is built into the streaming
> pipeline design of ITK.  All computation of appropriate regions should
> occur if the filters are implemented correctly.  To take advantage of
> streaming, place the StreamingImageFilter [1] at the end of your
> pipeline. To use less memory, set the ReleaseDataFlagOn() [2] on the
> component filters.
>
> HTH,
> Matt
>
> [1] http://www.itk.org/Doxygen/html/classitk_1_1StreamingImageFilter.html
>
> [2]
> http://www.itk.org/Doxygen/html/classitk_1_1ProcessObject.html#ae732e9163879ae559ccd0b5957141f97
>
> On Mon, Mar 16, 2015 at 10:20 AM, Bradley Lowekamp
> <blowekamp at mail.nih.gov> wrote:
> > You may find this method useful:
> >
> >
> http://www.itk.org/Doxygen/html/structitk_1_1ImageAlgorithm.html#a5ec5bcac992cb3b1302840636530ba20
> >
> > Brad
> >
> > On Mar 16, 2015, at 10:16 AM, Pol Monsó Purtí <lluna.nova at gmail.com>
> wrote:
> >
> > Mmh, I believe I misread the RegionOfInterestImageFilter documentation,
> > confusing dimension with size. That should work.
> >
> > I still have the computation of the splitting regions problem to handle,
> but
> > maybe with this filter is easier than with the ExtractImageFilter. Or
> maybe
> > it just removes step 7?
> >
> > Is there a way to ease the repasting back to the original region with it?
> > How should I use the physical space index?
> >
> > 2015-03-16 14:25 GMT+01:00 Pol Monsó Purtí <lluna.nova at gmail.com>:
> >>
> >> Hello Bradley,
> >>
> >> Thank you for your answer and suggestion.
> >>
> >> Answering your question: It's not for multi-threading purposes, I have
> to
> >> split the image due to memory limitations.
> >>
> >> I would use extractImage directly and do streaming, but the client and
> the
> >> low-level libraries might not work correctly if I do that. I have to
> provide
> >> itk images disconnected from the pipeline and with proper indexes and
> sizes.
> >>
> >> The RegionOfInterestImageFilter would have the same memory footprint,
> and
> >> it would still be tricky to compute the regions of interest, due to the
> >> overlapping.
> >>
> >>
> >>
> >> 2015-03-16 14:00 GMT+01:00 Bradley Lowekamp <blowekamp at mail.nih.gov>:
> >>>
> >>> Hello,
> >>>
> >>> The RegionOfInterestImageFilter[1] is very similar to the
> >>> ExtractImageFilter, but returns an image whose starting index is always
> >>> zeros.
> >>>
> >>> The process you described is remarkable close to what occur in each
> >>> filter for the multi-threading process.  Also what occurs in the
> >>> StreamingImageFilter is very similar, but just copies the region.
> >>>
> >>> As you didn't mention you motivation for chunking the data this way be
> it
> >>> for threading or memory requirements, I can't fully advise.
> >>>
> >>> Brad
> >>>
> >>>
> >>> [1
> >>> ]
> http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html
> >>> [2]
> >>>
> https://github.com/InsightSoftwareConsortium/ITK/blob/b184194869ac6407fcbb4e309710894cfc84466f/Modules/Core/Common/include/itkStreamingImageFilter.hxx#L194-L213
> >>>
> >>>
> >>> On Mar 16, 2015, at 7:37 AM, Pol Monsó Purtí <lluna.nova at gmail.com>
> >>> wrote:
> >>>
> >>> > Hello everyone,
> >>> >
> >>> > We need to split a volume into pieces, overlaped by a certain amount,
> >>> > do some computation and then repaste them.
> >>> >
> >>> > The computation requires the pieces' region indexes to be set to
> zero.
> >>> > The original volume might not have index at zero, but be a subregion
> itself.
> >>> >
> >>> > What is the best way to achieve this?
> >>> >
> >>> > I've thought of the following pipeline:
> >>> >
> >>> > 1. imageRegionSplitterSlowDimension
> >>> > 2. Store the index and size of each region
> >>> > 3. manually increase the size of each region (and modify index)
> >>> > 4. crop with the largestPossibleRegion of the original volume (to
> >>> > prevent requesting more than available)
> >>> > iterate over regions:
> >>> >       5. extractImageFilter
> >>> >       6. disconnect pipeline for each region
> >>> >       7. reset indexes
> >>> >       8. perform computation
> >>> >       9. crop with the regions in step 1 to remove the added overlap
> >>> >       10. restore indexes
> >>> > 11. pasteImageFilter
> >>> >
> >>> > I'll have to think of a smart way to deal with the index
> >>> > restore/cropping of steps 9 and 10.
> >>> >
> >>> > I somehow feel somebody will have already dealt with this... And
> >>> > there's certainly a better way to do it.
> >>> > _____________________________________
> >>> > Powered by www.kitware.com
> >>> >
> >>> > Visit other Kitware open-source projects at
> >>> > http://www.kitware.com/opensource/opensource.html
> >>> >
> >>> > Kitware offers ITK Training Courses, for more information visit:
> >>> > http://www.kitware.com/products/protraining.php
> >>> >
> >>> > Please keep messages on-topic and check the ITK FAQ at:
> >>> > http://www.itk.org/Wiki/ITK_FAQ
> >>> >
> >>> > Follow this link to subscribe/unsubscribe:
> >>> > http://public.kitware.com/mailman/listinfo/insight-users
> >>>
> >>
> >>
> >> 2015-03-16 14:00 GMT+01:00 Bradley Lowekamp <blowekamp at mail.nih.gov>:
> >>>
> >>> Hello,
> >>>
> >>> The RegionOfInterestImageFilter[1] is very similar to the
> >>> ExtractImageFilter, but returns an image whose starting index is always
> >>> zeros.
> >>>
> >>> The process you described is remarkable close to what occur in each
> >>> filter for the multi-threading process.  Also what occurs in the
> >>> StreamingImageFilter is very similar, but just copies the region.
> >>>
> >>> As you didn't mention you motivation for chunking the data this way be
> it
> >>> for threading or memory requirements, I can't fully advise.
> >>>
> >>> Brad
> >>>
> >>>
> >>> [1
> >>> ]
> http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html
> >>> [2]
> >>>
> https://github.com/InsightSoftwareConsortium/ITK/blob/b184194869ac6407fcbb4e309710894cfc84466f/Modules/Core/Common/include/itkStreamingImageFilter.hxx#L194-L213
> >>>
> >>>
> >>> On Mar 16, 2015, at 7:37 AM, Pol Monsó Purtí <lluna.nova at gmail.com>
> >>> wrote:
> >>>
> >>> > Hello everyone,
> >>> >
> >>> > We need to split a volume into pieces, overlaped by a certain amount,
> >>> > do some computation and then repaste them.
> >>> >
> >>> > The computation requires the pieces' region indexes to be set to
> zero.
> >>> > The original volume might not have index at zero, but be a subregion
> itself.
> >>> >
> >>> > What is the best way to achieve this?
> >>> >
> >>> > I've thought of the following pipeline:
> >>> >
> >>> > 1. imageRegionSplitterSlowDimension
> >>> > 2. Store the index and size of each region
> >>> > 3. manually increase the size of each region (and modify index)
> >>> > 4. crop with the largestPossibleRegion of the original volume (to
> >>> > prevent requesting more than available)
> >>> > iterate over regions:
> >>> >       5. extractImageFilter
> >>> >       6. disconnect pipeline for each region
> >>> >       7. reset indexes
> >>> >       8. perform computation
> >>> >       9. crop with the regions in step 1 to remove the added overlap
> >>> >       10. restore indexes
> >>> > 11. pasteImageFilter
> >>> >
> >>> > I'll have to think of a smart way to deal with the index
> >>> > restore/cropping of steps 9 and 10.
> >>> >
> >>> > I somehow feel somebody will have already dealt with this... And
> >>> > there's certainly a better way to do it.
> >>> > _____________________________________
> >>> > Powered by www.kitware.com
> >>> >
> >>> > Visit other Kitware open-source projects at
> >>> > http://www.kitware.com/opensource/opensource.html
> >>> >
> >>> > Kitware offers ITK Training Courses, for more information visit:
> >>> > http://www.kitware.com/products/protraining.php
> >>> >
> >>> > Please keep messages on-topic and check the ITK FAQ at:
> >>> > http://www.itk.org/Wiki/ITK_FAQ
> >>> >
> >>> > Follow this link to subscribe/unsubscribe:
> >>> > http://public.kitware.com/mailman/listinfo/insight-users
> >>>
> >>
> >
> >
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.php
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/insight-users
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150317/1e4f044a/attachment.html>


More information about the Insight-users mailing list