[Insight-users] Filtering region by region an image

Miller, James V (Research) millerjv@crd.ge.com
Fri, 21 Feb 2003 09:55:52 -0500


Mathieu,

Seeing you last post, it is clear that I misunderstood your question.

Given your picture below:

> A is the image I read from file (FileReader) but I want to process 
> *only* the subregion B of this image and then write back an image of 
> same dimension as A but with the subregion B filtered.


-----------------------------------
| A                               |
|                                 |
|   --------                      |
|   |  B   |         --------     |
|   --------         |   E  |     |
|       --------     --------     |
|       |  C   | --------         |
|       -------- |  D   |         |
|                --------         |
|                                 |
-----------------------------------

You can have your filter just process the region B via the methods
you have been looking

someFilter->SetInput( someReader->GetOutput() );
someFilter->GetOutput()->SetRequestedRegion( bRegion );
someFilter->Update();

This will tell "someFilter" to just process the region of the input
image labelled B.  The output of someFilter will be just the processed
region. You could also extract the initial region using the ExtractImageFilter
but that would copy the data an extra time.

This is almost what you want.  What is missing is an ability to 
paste this result back into image A.  Someone here was supposed to 
write a filter to do this but apparently it did not get into
the toolkit.  I'll check around.

If it did exist (and it was called itk::PasteImageFilter), then your
pipeline could look like

someFilter->SetInput( someReader->GetOutput() );
someFilter->GetOutput()->SetRequestedRegion( bRegion );
someFilter->Update();

pasteFilter->SetInput1( someReader->GetOutput() );
pasteFilter->SetInput2( someFilter->GetOutput() );
pasteFilter->Update();

You would then grab the output of the pasteFilter to show in your gui.
There might have to be some additional API to handle the case where
someone wants to paste a small image into a bigger image and specify
"where" the small image should go.

I'll put the PasteImageFilter on my list of things to do.

Jim







> -----Original Message-----
> From: Mathieu Malaterre 
> [mailto:Mathieu.Malaterre@creatis.insa-lyon.fr]
> Sent: Friday, February 21, 2003 8:34 AM
> To: Miller, James V (Research)
> Subject: Re: [Insight-users] Filtering region by region an image
> 
> 
> James,
>     I am answering off list. As I wrote in:
> 
> http://www.itk.org/pipermail/insight-users/2003-February/002614.html
> 
> Your solution to use StreamingImageFilter is a bit confusing. 
> I am not 
> trying to work on a image to big to be loaded in memory. I am 
> trying to 
> filter *some* regions of my initial image.
> 
> I though it should be an easy job due to ITK design. I don't 
> understand 
> why I can't give an ImageRegion to the filter and work by reference 
> instead of copy.
> 
> Anyway thank you for your answer...it seems that ITK user 
> group is ready 
> to work without Luis's answers.
> 
> mathieu
> 
> Miller, James V (Research) wrote:
> > If you put a StreamingImageFilter at the end of your 
> pipeline, and set
> > the number of divisions to 4, then the StreamingImageFilter 
> will execute
> > the upstream pipeline 4 times each with a different RequestedRegion 
> > and tile the results into a single image.  Unfortunately, the 
> > default ImageRegionSplitter used by the 
> StreamingImageFilter will divide
> > your input image like
> > 
> >   ---------------------------
> >  |            1              |
> >  |---------------------------|
> >  |            2              |
> >  |---------------------------|
> >  |            3              |
> >  |---------------------------|
> >  |            4              |
> >   ---------------------------
> > 
> > But if you set the RegionSplitter (via the 
> SetRegionSplitter() method on the StreamingImageFilter) to
> > a itk::ImageRegionMultipleDimensionSplitter you can control 
> the splits to be 
> > 
> >   ---------- ----------
> >   |         |         |
> >   |         |         |
> >   |    1    |     2   |
> >   |         |         |
> >   ---------- ----------
> >   |         |         |
> >   |         |         |
> >   |    3    |     4   |
> >   |         |         |
> >   ---------------------
> > 
> > I haven't tried this in a while so let me know if you have 
> any problems.  Also, using the
> > StreamingImageFilter assumes that the upstream pipeline 
> support streaming. 
> > 
> > 
> > 
> > 
> > 
> >>-----Original Message-----
> >>From: Mathieu Malaterre 
> >>[mailto:Mathieu.Malaterre@creatis.insa-lyon.fr]
> >>Sent: Thursday, February 20, 2003 10:33 AM
> >>To: ITK Users
> >>Subject: [Insight-users] Filtering region by region an image
> >>
> >>
> >>Hi all,
> >>
> >>   I would like to know, how I can work on a region of an 
> >>image. I tried 
> >>to do it with ExtractImageFilter but I fail to make it work.
> >>
> >>   The output of the filter where of the size of the 
> extracted region 
> >>(which is the way ExtractImageFilter is supposed to work: decrease 
> >>size), but I wanted it to be of size of the initial image 
> (= input of 
> >>ExtractImageFilter)
> >>
> >>   Basically here is what I want to do. Let say I have an 
> >>image that I 
> >>want to filter on 4 distinct parts (not necesseraly identical).
> >>
> >>---------- ----------
> >>|         |         |
> >>|         |         |
> >>|    1    |     2   |
> >>|         |         |
> >>---------- ----------
> >>|         |         |
> >>|         |         |
> >>|    3    |     4   |
> >>|         |         |
> >>---------------------
> >>
> >>   Could someone give me the pipeline to use ? So that at the 
> >>end I have 
> >>filtered the whole image (I don't know how to concat images 
> >>after having 
> >>them extracted through ExtractImageFilter).
> >>
> >>   Should I use ImageRegion/ ImageRegionIterator/ 
> ExtractImageFilter ?
> >>
> >>   Hoping to be clear,
> >>
> >>   Thank you,
> >>   Mathieu Malaterre
> >>
> >>
> >>-- 
> >>Mathieu Malaterre
> >>CREATIS
> >>28 Avenue du Doyen LEPINE
> >>B.P. Lyon-Montchat
> >>69394 Lyon Cedex 03
> >>http://www.creatis.insa-lyon.fr/~malaterre/
> >>
> >>_______________________________________________
> >>Insight-users mailing list
> >>Insight-users@public.kitware.com
> >>http://public.kitware.com/mailman/listinfo/insight-users
> >>
> > 
> > 
> 
> 
> -- 
> Mathieu Malaterre
> CREATIS
> 28 Avenue du Doyen LEPINE
> B.P. Lyon-Montchat
> 69394 Lyon Cedex 03
> http://www.creatis.insa-lyon.fr/~malaterre/
>