public void learnFernNoise ( boolean positive , ImageRectangle r ) { float rectWidth = r . getWidth ( ) ; float rectHeight = r . getHeight ( ) ; float c_x = r . x0 + ( rectWidth - 1 ) / 2.0f ; float c_y = r . y0 + ( rectHeight - 1 ) / 2.0f ; for ( int i = 0 ; i < ferns . length ; i ++ ) { // first learn it with no noise int value = computeFernValue ( c_x , c_y , rectWidth , rectHeight , ferns [ i ] ) ; TldFernFeature f = managers [ i ] . lookupFern ( value ) ; increment ( f , positive ) ; for ( int j = 0 ; j < numLearnRandom ; j ++ ) { value = computeFernValueRand ( c_x , c_y , rectWidth , rectHeight , ferns [ i ] ) ; f = managers [ i ] . lookupFern ( value ) ; increment ( f , positive ) ; } } }
Computes the value for each fern inside the region and update s their P and N value . Noise is added to the image measurements to take in account the variability .