[Insight-users] Getting unknown amount random Pixels

N.E. Mackenzie Mackay 9nem at qlink.queensu.ca
Sun Sep 12 16:45:22 EDT 2004


Hi,

	I am currently trying to get a set of N number of Pixels in a image in 
random locations over a set threshold.  I was attempting to use 
ImageRandomConstIteratorWithIndex but have come to realize that you 
need to set the number of samples you will be using before starting the 
iterator.  My problems is I don't know how many pixels I need to sample 
before getting N pixels over the threshold.

Here is my code:

	typedef ImageRandomConstIreratorWithIndex<ImageType> RandomIterator;
	RandomIterator randIter( M_FixedImage, this->GetFixedImageRegion())

	randIter.SetNumberOfSamples( m_NumberOfSpatialSamples );
	randIter.GoToBegin();

	RandomIterator ::PixelType pixelValue;
	
	for(int i = 0; i< N; i++)
	{
		pixelValue = randIter.Get();
		
		while(PixelValue == 0)
		{
			++randIter;
			pixelValue = randIter.Get();
		}
		printf("pixel value = %e \n", pixelValue);

		container[i] = pixelValue;
	}

	The stuff that is printed to the screen is something like 8.61e-304

Even when I simply try to use "get" some strange number comes out.  Is 
it because get doesn't return a float or double but a object of some 
kind of container?

Neilson



More information about the Insight-users mailing list