code: protected void selectBestRegionsFern(double totalP, double totalN) {
  
  		for( int i = 0; i < fernInfo.size; i++ ) {
  			TldRegionFernInfo info = fernInfo.get(i);
  
  			double probP = info.sumP/totalP;
  			double probN = info.sumN/totalN;
  
  			// only consider regions with a higher P likelihood
  			if( probP > probN ) {
  				// reward regions with a large difference between the P and N values
  				storageMetric.add(-(probP-probN));
  				storageRect.add( info.r );
  			}
  		}
  
  		// Select the N regions with the highest fern probability
  		if( config.maximumCascadeConsider < storageMetric.size ) {
  			int N = Math.min(config.maximumCascadeConsider, storageMetric.size);
  			storageIndexes.resize(storageMetric.size);
  
  			QuickSelect.selectIndex(storageMetric.data, N - 1, storageMetric.size, storageIndexes.data);
  			for( int i = 0; i < N; i++ ) {
  				fernRegions.add(storageRect.get(storageIndexes.get(i)));
  			}
  		} else {
  			fernRegions.addAll(storageRect);
  		}
  	}
docs: compute the probability that each region is the target conditional upon this image
  the sumP and sumN are needed for image conditional probability
  
  NOTE: This is a big change from the original paper