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

Bert albermnz at gmail.com
Thu Apr 24 12:57:32 EDT 2008


Hi Luis,

Thanks a lot for your answer. What I am trying to do is to implement a
reconstruction algorithm. I haven't used any of the implemented ones because
I need to use my own structuring element.
What I have to do is dilatation + intersection until the convergence, this
is why I need to modify the output of the Dilate filter. Is possible to do
it? This is the code I have:

    InputImageType::Pointer marker = InputImageType::New();
    InputImageType::Pointer markerDilated = InputImageType::New();
    InputImageType::Pointer mask = InputImageType::New();

    marker = readerMarker->GetOutput();   //read the marker image
    markerDilated = grayscaleReconstruction->GetOutput();   //read the
dilated marker
    mask = readerMask->GetOutput();       //read the mask image

    // Next we create two iterators.  The iterators are initialized over the
same region.
    //The direction of iteration is set to 0, the $x$ dimension.
    IteratorType markerDilatedIt( markerDilated,
markerDilated->GetRequestedRegion() );
    IteratorType maskIt( mask, mask->GetRequestedRegion() );
    markerDilatedIt.SetDirection(0);
    maskIt.SetDirection(0);

    grayscaleReconstruction->SetKernel( structuringElement );
    WriterType::Pointer writerMarkerDilated = WriterType::New();

    for (int i =0; i<numberOfIterations; i++)
    {
        grayscaleReconstruction->SetInput( marker );
        grayscaleReconstruction->Update();


        for ( markerDilatedIt.GoToBegin(),  maskIt.GoToBegin(); !
maskIt.IsAtEnd();
            markerDilatedIt.NextLine(),  maskIt.NextLine())
        {
            markerDilatedIt.GoToBeginOfLine();
            maskIt.GoToBeginOfLine();

            while ( ! markerDilatedIt.IsAtEndOfLine() )
            {
                if( maskIt.Get()==0 )
                {
                    markerDilatedIt.Set( 0 );
                    ++markerDilatedIt;
                    ++maskIt;
                }
                else
                {
                    ++markerDilatedIt;
                    ++maskIt;
                }
            }
        }
        writerMarkerDilated->SetFileName( argv[2] );  //overwrite the marker
        writerMarkerDilated->SetInput(markerDilated);
        writerMarkerDilated->Update();

        readerMarker->Update();
        marker->Update();


    }

Thanks a lot for your reply
Best
Bert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080424/0b125fe3/attachment.htm>


More information about the Insight-users mailing list