[Insight-users] How to get a progess from an iterator?
lynx.abraxas at freenet.de
lynx.abraxas at freenet.de
Tue Dec 8 15:09:28 EST 2009
On 06/12/09 18:24:51, Luis Ibanez wrote:
> Hi Lynx,
>
> 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.
>
Thank You very much Luis. This was exacly what I was trying to do but I didn't
find a way to get the total number of pixels...
I had some strange problem though:
As I started from the ShapedNeighborhoodIterator example form the users guide
(which is in 2D) I had modified things to my need and changed to 3D.
Somehow that all worked until I needed the new variables for the progress.
Just from declaring a variable I got a segfault. Changing the position of the
declaration solved the problem for one variable but not for the rest.
I finally figured out after hours that the problem was the uninitialized third
dimension of the iterator neighbourhood. If I'm not mistaken such a problem
was discussed a few weeks before here on the list...
I now wonder if there is a way to prevent this in futur programming by a
cleaner or more secure programming style. Is there a way to prevent such
faults? Or at least to help the compiler find uninitialized components of an
array for reporting at compile time?
Also I found the cool code below to easily implement 2D and 3D programs. Is
there any chance to make that work also with a ShapedNeighborhoodIterator
who's neighbourhood (a ball) needs to be initialize once in 2D and once in 3D?
Thanks again Luis for Your help.
Lynx
___________________________
int main( int argc, char *argv[] ){
if ( argc < 8 ){
std::cerr << "Missing parameters. " << std::endl;
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< "ImageDimension inputImageFile outputImageFile element_radius foreground background maskground"
<< std::endl;
return -1;
}
unsigned int dim;
dim= atoi(argv[1]);
argv++; //shift();
argc--;
switch(dim)
{
case 2:
masked_mean_filter<2>( argc, argv );
break;
case 3:
masked_mean_filter<3>( argc, argv );
break;
default:
std::cerr << "Unsupported dimension" << std::endl;
exit( EXIT_FAILURE );
}
}
More information about the Insight-users
mailing list