[Insight-users] pixel access of filter output image
Jie Zhu
zhujie1979 at gmail.com
Fri Oct 29 16:10:39 EDT 2004
Thank you, Luis.
-Jie
On Fri, 29 Oct 2004 15:16:20 -0400, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
> Hi Jie,
>
> 1) You shouldn't take the region for the iterator from
> the RequestedRegion of the filter.
>
> 2) You don't seem to need to use the LinearIterators,
> it will be simpler to use the plain ImageRegionIterator.
>
> Like:
>
> ImageType::Pointer image = smoothing->GetOutput();
>
> typedef itk::ImageRegionIterator<ImageType> IteratorType;
>
> IteratorType it( image, image->GetBufferedRegion() );
>
> it.GoToBegin();
> while( !it.IsAtEnd() )
> {
> PixelType value = it.Get();
> ++it;
> }
>
> Regards,
>
> Luis
>
> -----------------
>
>
> Jie Zhu wrote:
>
> > Hi All,
> > I am having trouble when I try to access pixels in an image output by
> > a smoothing (or other types of ) filter.
> > I have a smoothing filter like below and I gave it some input image, I
> > checked the output image and it is working fine. But if I try to
> > access pixels in this output image using iterators it just crashes.
> > Why is this happening?
> > Thanks a lot,
> > Jie
> >
> > typedef float InternalPixelType;
> > const unsigned int Dimension = 2;
> > typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
> >
> > typedef itk::CurvatureAnisotropicDiffusionImageFilter<
> > InternalImageType,
> > InternalImageType > SmoothingFilterType;
> >
> > SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
> > smoothing->SetInput( reader->GetOutput() );
> >
> > typedef itk::ImageLinearIteratorWithIndex< InternalImageType > IteratorType;
> >
> > IteratorType it( smoothing->GetOutput(), smoothing->GetRequestedRegion() );
> > it.SetDirection(0);
> > for ( it.GoToBegin(); ! it.IsAtEnd();it.NextLine()){
> > it.GoToBeginOfLine();
> > float pixelValue;
> > InternalImageType::IndexType tmpIndx;
> > while ( ! it.IsAtEndOfLine() ){
> > pixelValue = it.Get(); //<--------------------- crashes here
> > ++it;
> > }
> > }
> > _______________________________________________
>
>
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
>
>
--
Jie Zhu
Cornell University
More information about the Insight-users
mailing list