[Insight-users] How to get a progess from an iterator?
Luis Ibanez
luis.ibanez at kitware.com
Sun Dec 6 18:24:51 EST 2009
Hi Lynx,
Yes, the Progress reporter is used normally inside
the GenerateData() method of a filter.
You could move your code into a filter, although,
this may be more involved than what you were
looking for....
---
A simpler option is to just insert a counter inside
the while-loop of the iterators. That's after all,
what the code of the ProgressReporter does.
The code will look like:
ImageIterator input1( image, region );
unsigned int numberOfPixels = region.GetNumberOfPixels();
inputIt1.GoToBegin();
unsigned int counter = 0;
unsigned int localLimit = numberOfPixels / 100;
while( !inputIt1.IsAtEnd() )
{
... // do the iterator processing.
++inputIt1;
++counter;
if ( counter % localLimit == 0 )
{
counter=0;
const double progress = (double)(counter) / (double)(numberOfPixels);
std::cout << "Progress = " << progress << std::endl;
}
}
Regards
Luis
---------------------------------------------------------------
On Sun, Dec 6, 2009 at 5:08 PM, <lynx.abraxas at freenet.de> wrote:
> On 06/12/09 16:48:25, Luis Ibanez wrote:
>> Hi Lynx,
>>
>> Nope,
>> In practice, the progress reporting functionalities have
>> been implemented by using the ProgressReporter
>> class, and by inter-twining it in the while-loop of the
>> iterator.
>>
>
> Thanks Luis for Your answer.
> I stepped over ProgressReporter but I don't know where to get the variables
> from I have to pass to ProgressReporter progress() when I use the iterator in
> main like in the example: ShapedNeighborhoodIterators1.cxx.
>
> So am I correct in assuming that I'd have to transform that main into an
> independent itk filter which I then include and call in my main program?
>
> Thanks
> Lynx
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list