[Insight-users] pixel access of filter output image

Miller, James V (Research) millerjv at crd.ge.com
Fri Oct 29 12:08:03 EDT 2004


Jie, 

You need to call Update() on the smoothing filter so that it will generate
the pixels.  Then you can create an iterator to walk the output.

Jim

-----Original Message-----
From: Jie Zhu [mailto:zhujie1979 at gmail.com]
Sent: Friday, October 29, 2004 11:47 AM
To: insight-users at itk.org
Subject: [Insight-users] pixel access of filter output image


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


More information about the Insight-users mailing list