[Insight-users] Modifying the output of an ITK filter with iterators.

Luis Ibanez luis.ibanez at kitware.com
Tue, 10 Feb 2004 13:13:28 -0500


Hi Radhika,

Well, if you are certain that the pipeline
is never going to be run a second time, then
you are probably in a safe situation.

To be completly safe you should probably
disconnect the image from the filter before
you altere its content with the iterators.

You can do it with a call like


    ImageType::Pointer image = filter->GetOutput();

    image->DisconnectPipeline();




Regards,


    Luis


------------------------------
Radhika Sivaramakrishna wrote:

> Hi Luis,
> Let me look at my code in more detail. I thought I had already updated 
> the previous filter and captured its output in my "mask". So the 
> previous pipeline, as far as I am concerned is done. I then start my new 
> pipeline
> 
> With mask and call a sequence of filters and then call update on that. 
> Since
> This is not in a for loop or anything, why is it wrong? I understand 
> your point about pipelines in general and not messing with the pointers, 
> but I am
> 
> Not sure it applies here.
> Let me know.
> Thanks
> Radhika
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
> Sent: Monday, February 09, 2004 7:28 PM
> To: Radhika Sivaramakrishna
> Cc: ITK; Miller, James V (Research)
> Subject: Re: [Insight-users] Masking a region & thresholding
> 
> 
> Hi Radhika,
> 
> You certainly don't want to use iterators
> for altering directly an image in the
> middle of the pipeline.  All your changes
> will be lost the next time you update the
> filters.
> 
> You should probably look at the AND, OR
> filter and actually mask the gray levels
> of the input image using your mask. Then
> continue the pipeline with an image that
> has the original gray level on the region
> of the mask and zeros elsewhere.
> 
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1OrImageFilter.html
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1AndImageFilter.html
> 
> 
> Regards,
> 
> 
>     Luis
> 
> 
> -------------------------------
> Radhika Sivaramakrishna wrote:
> 
>  > Hi Luis,
>  >
>  > Thanks for entering this as a bug.
>  > You are right about the cumulators. I should declare them as float.
>  > I do not understand the issue you pointed to below.
>  >
>  > I am forced to do my calculations this way because what I want to do is
>  > the following:
>  >
>  > Use the histogram analysis to identify a threshold to threshold the
>  > image. But I want to do the thresholding only in the region of the mask.
>  > Ie I am basically happy my mask, except it also includes regions in the
>  > original image that are higher than the threshold which I want to 
> remove.
>  >
>  > If
>  > I just use this threshold through a standard Threshold filter, then I
>  > will end up with a lot of other regions (values lower than this
>  > threshold that I don't need), so I am constraining this thresholding
>  > only in the region of the mask, so I am directly editing the ON pixels
>  > in my mask to switch off at regions in the gray level that are higher
>  > than threshold. Is there a better way to do this?
>  >
>  > Radhika
>  >
>  >
>  > -----Original Message-----
>  > From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
>  > Sent: Monday, February 09, 2004 11:59 AM
>  > To: Radhika Sivaramakrishna
>  > Cc: ITK; Miller, James V (Research)
>  > Subject: Re: [Insight-users] Compilation error with inPlace filters
>  >
>  >
>  > Hi Radhika,
>  >
>  > This seems to be a bug in the RelabelImageFilter.
>  > The issue has been entered in the bug tracker with ID # 582
>  >
>  > http://www.itk.org/Bug/bug.php?op=show&bugid=582&pos=0 
> <http://www.itk.org/Bug/bug.php?op=show&bugid=582&pos=0>
>  > <http://www.itk.org/Bug/bug.php?op=show&bugid=582&pos=0 
> <http://www.itk.org/Bug/bug.php?op=show&bugid=582&pos=0>>
>  >
>  > In the meantime, please instantiate the RelabelImageFilter
>  > using the same image type for input and output.
>  >
>  > ----
>  >
>  > Unrelated to the error above,... but still worrisome:
>  >
>  > In your code you are taking the output of a reader and
>  > using an iterator for changing the value of this image.
>  > (the "mask" image in lines 193 - 201 ).
>  >
>  > Then you pass the image as input to another filter.
>  > This is a violation of the pipeline encapsulation.
>  > You should use a threshold image filter instead of
>  > using an iterator through the image. The output of the
>  > filters should be const...  but we still have this
>  > weakness in ITK filters....
>  >
>  > The cumulators that you have for frequencies are
>  > being declared unsigned long. They should be floats
>  > or doubles.  Note that Frequencies are not just counters,
>  > they actually provide floating point values.
>  >
>  >
>  >   Regards,
>  >
>  >
>  >      Luis
>  >
>  >
>  > ---------------------------------------
>  > Radhika Sivaramakrishna wrote:
>  >
>  >  > Hi Luis,
>  >  > I actually did the checkout this morning and I did see the Dashboard
>  >  > was pretty green. I don't know if I am making a silly mistake or a
>  >  > more serious error.
>  >  >
>  >  > I have copied my code here which doesn't compile and gives the error
>  >  > indicated below. I think the problem has something to do with the
>  >  > IntImageType I put in for dealing with the Relabel.. filter.
>  >  >
>  >  > Sorry about not putting the correct subject. Will try to make sure to
>  >  > do it from now on.
>  >  >
>  >  > Radhika
>  >  >
>  >  >
>  >  > -----Original Message-----
>  >  > From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
>  >  > Sent: Monday, February 09, 2004 10:34 AM
>  >  > To: Radhika Sivaramakrishna
>  >  > Cc: ITK
>  >  > Subject: Re: [Insight-users] Compilation error with inPlace filters
>  >  >
>  >  >
>  >  > Hi Radhika,
>  >  >
>  >  >
>  >  > A number of changes were made last week for extending
>  >  > the functionality of "InPlace" filters.
>  >  >
>  >  > You probably updated your checkout in the middle of
>  >  > one of such modifications.  Please trying cvs updating
>  >  > to this morning (since the nightly Dashboard was quite
>  >  > green today).
>  >  >
>  >  >
>  >  >   Regards,
>  >  >
>  >  >
>  >  >      Luis,
>  >  >
>  >  >
>  >  > PS. Please don't reuse email threads with other subjects when
>  >  >       you post questions about new topics/problems. This is
>  >  >      confusing for anybody trying to follow a thread.
>  >  >
>  >  >
>  >  > ---------------------------------------
>  >  > Radhika Sivaramakrishna wrote:
>  >  >
>  >  > > Hi Luis,
>  >  > > I am getting this very strange error message while compiling. 
> Can you
>  >  > > explain what this could be?
>  >  > >
>  >  > > /home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx: In
>  > member
>  >  > >    function `void itk::InPlaceImageFilter<TInputImage,
>  >  > >    TOutputImage>::AllocateOutputs() [with TInputImage = main(int,
>  >  > >    char**)::IntImageType, TOutputImage = main(int,
>  >  > char**)::ImageType]':
>  >  > > /home/rsivaram/Insight/Code/Common/itkImageRegion.h:173:
>  >  > > instantiated from here
>  >  > > /home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx:76: no
>  >  > > matching
>  >  > >    function for call to `itk::InPlaceImageFilter<main(int,
>  >  > >    char**)::IntImageType, main(int,
>  >  > > char**)::ImageType>::GraftOutput(main(int,
>  >  > >    char**)::IntImageType*)'
>  >  > > /home/rsivaram/Insight/Code/Common/itkImageSource.txx:95: 
> candidates
>  >  > > are: void
>  >  > >    itk::ImageSource<TOutputImage>::GraftOutput(TOutputImage*) [with
>  >  > >    TOutputImage = main(int, char**)::ImageType]
>  >  > >
>  >  > >
>  >  > > Thanks
>  >  > > Radhika
>  >  > >
>  >  > >
>  >  > >
>  >  >
>  >  >
>  >  >                                                   
>  >  > -----------------------------------------------------
>  >  > Confidentiality Notice.
>  >  > This email message is for the sole use of the intended recipient(s)
>  >  > and may contain confidential and privileged information. Any
>  >  > unauthorized review, use, disclosure or distribution is 
> prohibited. If
>  >  > you are not the intended recipient, please contact the sender by 
> reply
>  >  > email and destroy all copies of the original message. If you are the
>  >  > intended recipient, please be advised that the content of this 
> message
>  >  > is subject to access, review and disclosure by the sender's Email
>  >  > System Administrator.
>  >  >
>  >  >
>  >  >
>  >  >
>  >  >
>  >
>  >
>  >
>  >                                                    
>  > -----------------------------------------------------
>  > Confidentiality Notice.
>  > This email message is for the sole use of the intended recipient(s) and
>  > may contain confidential and privileged information. Any unauthorized
>  > review, use, disclosure or distribution is prohibited. If you are not
>  > the intended recipient, please contact the sender by reply email and
>  > destroy all copies of the original message. If you are the intended
>  > recipient, please be advised that the content of this message is subject
>  > to access, review and disclosure by the sender's Email System 
> Administrator.
>  >
> 
> 
>                                                     
> ----------------------------------------------------- 
> Confidentiality Notice.
> This email message is for the sole use of the intended recipient(s) and 
> may contain confidential and privileged information. Any unauthorized 
> review, use, disclosure or distribution is prohibited. If you are not 
> the intended recipient, please contact the sender by reply email and 
> destroy all copies of the original message. If you are the intended 
> recipient, please be advised that the content of this message is subject 
> to access, review and disclosure by the sender's Email System Administrator.
>