[Insight-users] itkImageRegionIterator question
Luis Ibanez
luis.ibanez@kitware.com
Fri, 06 Sep 2002 11:08:33 -0400
Hi Mathieu,
Did you invoked "Update()" in the ClipRescaleIntensityImageFilter
before attempting to read the output with the iterator ?
The output of the filter is only valid after Update() is executed.
Please try adding a line like:
itkClipRescaleIntensityImageFilterPtr_a->Update();
after the lines with SetOutputMinimum and SetOutputMaximum.
Also, there is a performance trade off between the two iterators:
a) - itkImageRegionIterator
b) - itkImageRegionIteratorWithIndex
(a) is faster if you are only reading the pixels
values using "Get()". This iterator doesn't keep internally
the values of pixel coordinates. That makes the call to
"GetIndex()" to be costly in computing time.
(b) keeps internally an updated Index with the current
position of the pixel. This makes it slower than (a)
for normal operations. However, when you also call
GetIndex(), the combined cost of Get() and GetIndex()
is much lower in (b) than in (a).
To summarize:
If you only want "Get()" then (a) is faster.
If you want "Get()" and "GetIndex()" then (b) is faster.
---
Please let us know if you encounter further problems,
Thanks
Luis
============================
Mathieu Lamard wrote:
> Dear All,
>
> I am using ITK since few months and I have some problems
>
> Here is my goal :
>
> To have an access the each pixel in an image (value + coordinates).
>
> It seems that itkImageRegionIterator is the good class to perform that.
>
> I have read http://www.itk.org/Doxygen/html/ImageIteratorsPage.html, I
> undersand the concept but I din't reach to use it correctly.
>
>
> here is my code :
>
> typedef itk::Image<float,2> FloatImageType_a;
> typedef itk::RescaleIntensityImageFilter<
> FloatImageType_a,
> FloatImageType_a >
> RescaleIntensityImageFilterType_a;
> RescaleIntensityImageFilterType_a::Pointer
> itkRescaleIntensityImageFilterPtr_a;
>
> ...
> ...
>
>
> itkClipRescaleIntensityImageFilterPtr_a->SetInput(itkGradientMagnitudeImageFilterPtr_a->GetOutput());
>
> itkClipRescaleIntensityImageFilterPtr_a-> SetOutputMinimum(0);
> itkClipRescaleIntensityImageFilterPtr_a-> SetOutputMaximum(255);
>
> /* I try that but it does't work */
>
>
> typedef itk::ImageRegionIterator<FloatImageType_a>
> FloatImageRegionIteratorType_a;
>
> FloatImageRegionIteratorType_a
> it(itkClipRescaleIntensityImageFilterPtr_a->GetOutput(),itkClipRescaleIntensityImageFilterPtr_a->GetOutput()->GetRequestedRegion());
>
>
> it.GoToBegin();
>
> while(!it.IsAtEnd())
> {
> cerr << it.Get() << endl;
> ++it;
> }
>
>
> Is some one have the solution of my problem ?
> Thanks in advance
>
> Mathieu
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>