- randIter.SetNumberOfSamples( numberOfDemandedPixels * 1000 );
- randIter.GoToBegin();
- while( (!randIter.IsAtEnd()) && (numberOfValidPixels<=numberOfDemandedPixels) ) {
- // Get sampled index
- index = randIter.GetIndex();
-
- // Mask?
- if( m_FixedImageMask.IsNotNull() ) {
-
- // Check if the Index is inside the mask, translate index to point
- m_FixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
+ short att = 1;
+ short natts = 5;
+ while (att <= natts) {
+ if (m_Verbose) std::cout << "Attempt " << att << std::endl;
+
+ int count_out = 0;
+ int count_not_thres = 0;
+ clock_t c = clock();
+ randIter.ReinitializeSeed(c);
+ randIter.SetNumberOfSamples( numberOfDemandedPixels * 1000 );
+ randIter.GoToBegin();
+ //int cnt = 0;
+ while( (!randIter.IsAtEnd()) && (numberOfValidPixels<=numberOfDemandedPixels) ) {
+ // Get sampled index
+ index = randIter.GetIndex();
+ //if (m_Verbose) std::cout << "testing pixel " << index << std::endl;
+
+ // Mask?
+ if( m_FixedImageMask.IsNotNull() ) {
+
+ // Check if the Index is inside the mask, translate index to point
+ m_FixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
+
+ // If not inside the mask, ignore the point
+ if( !m_FixedImageMask->IsInside( inputPoint ) ) {
+ ++randIter; // jump to next pixel
+ //if (m_Verbose) std::cout << "not inside " << inputPoint << std::endl;
+ count_out++;
+ continue;
+ }