[Insight-users] how to update the content of an image

Luis Ibanez luis.ibanez at kitware.com
Thu Apr 24 11:18:43 EDT 2008


Hi Bert,

You seem to be missusing the pipeline architecture of ITK.

 From the description of you email, it seems that what you
want to do is to read an image and then pass it twice
through the GrayscaleDilateFilter.

The simplest way to achieve this is to use *two* Grayscale
DilateFilters one after another.

Your pipeline could look like:

    reader --> DilateFitler1 --> DilateFitler2

if after this you want to process a second image that you read
from a file, then what you need is to take the output of the
second DilateFilter and disconnect it from the pipeline by
calling

       grayscaleDilateFilter2->Update();

       ImageType::ConstPointer result1 =
             grayscaleDilateFilter2->GetOutput();

       result1->DisconnectPipeline();

       reader->SetFileName( "secondfile.mhd" );

       grayscaleDilateFilter2->Update();

       ImageType::ConstPointer result2 =
             grayscaleDilateFilter2->GetOutput();



In general you shouldn't modify an image that is the output
of a filter. Images that are produced by filters are *own*
by that filter, and any modification that you make to the
image will be lost when you rerun the pipeline.


BTW:

    If the purpose of the iterator wast to set the image
    to zeros, then you could have done that in a single
    call by using

         image->FillBuffer( zero );

    Also, Why do you use "false" ?
    are you using "bool" as the pixel type of your images ?




    Regards,


        Luis



-------------
Bert wrote:
> Dear all,
> 
> I would like to update the content of an image. I read an
> image from a file and then this image is passed, as an
> argument, in the itkGrayscaleDilateFilter. The output of
> this filter is then modificated and passed again in the
>  itkGrayscaleDilateFilter.How can I update the new content
> ok ReaderMk(see the code)?
> 
> InputImageType::Pointer mk = InputImageType::New();
> mk = readerMk->GetOutput();  
> IteratorType mkIt( mk, mk->GetRequestedRegion() );    
> 
>   mkIt.SetDirection(0);
>  
>   grayscaleDilate->SetKernel( structuringElement );
> 
>   for (int i =0; i<2; i++)
>   {
>       grayscaleDilate->SetInput( readerMk->GetOutput() );    //I would 
> like to update the readerMk
>       grayscaleDilate->Update();
> 
>           for ( markerIt.GoToBegin(); ! markerIt.IsAtEnd();
>           mkIt.NextLine())
>       {
>           makIt.GoToBeginOfLine();
>           while ( ! mkIt.IsAtEndOfLine() )
>           {
>               mkIt.Set( false );
>               ++mkIt;
>           }
>       }
>       readerMk->Update();     //Do I need to add something else?
> }
> 
> Thanks a lot for your help
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list