public void process ( ) { // compute match intensities if ( mask == null ) match . process ( template ) ; else match . process ( template , mask ) ; GrayF32 intensity = match . getIntensity ( ) ; int offsetX = 0 ; int offsetY = 0 ; // adjust intensity image size depending on if there is a border or not if ( ! match . isBorderProcessed ( ) ) { int x0 = match . getBorderX0 ( ) ; int x1 = imageWidth - ( template . width - x0 ) ; int y0 = match . getBorderY0 ( ) ; int y1 = imageHeight - ( template . height - y0 ) ; intensity = intensity . subimage ( x0 , y0 , x1 , y1 , null ) ; } else { offsetX = match . getBorderX0 ( ) ; offsetY = match . getBorderY0 ( ) ; } // find local peaks in intensity image candidates . reset ( ) ; extractor . process ( intensity , null , null , null , candidates ) ; // select the best matches if ( scores . length < candidates . size ) { scores = new float [ candidates . size ] ; indexes = new int [ candidates . size ] ; } for ( int i = 0 ; i < candidates . size ; i ++ ) { Point2D_I16 p = candidates . get ( i ) ; scores [ i ] = - intensity . get ( p . x , p . y ) ; } int N = Math . min ( maxMatches , candidates . size ) ; QuickSelect . selectIndex ( scores , N , candidates . size , indexes ) ; // save the results results . reset ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Point2D_I16 p = candidates . get ( indexes [ i ] ) ; Match m = results . grow ( ) ; m . score = - scores [ indexes [ i ] ] ; m . set ( p . x - offsetX , p . y - offsetY ) ; } }
Performs template matching .