Created
          April 5, 2011 19:42 
        
      - 
      
- 
        Save jhsu/904370 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | minSAD = VALUE_MAX; | |
| // loop through the search image | |
| for ( int x = 0; x <= S_rows - T_rows; x++ ) { | |
| for ( int y = 0; y <= S_cols - T_cols; y++ ) { | |
| SAD = 0.0; | |
| // loop through the template image | |
| for ( int i = 0; i < T_rows; i++ ) | |
| for ( int j = 0; j < T_cols; j++ ) { | |
| pixel p_SearchIMG = S[x+i][y+j]; | |
| pixel p_TemplateIMG = T[i][j]; | |
| SAD += abs( p_SearchIMG.Grey - p_TemplateIMG.Grey ); | |
| } | |
| } | |
| // save the best found position | |
| if ( minSAD > SAD ) { | |
| minSAD = SAD; | |
| // give me VALUE_MAX | |
| position.bestRow = x; | |
| position.bestCol = y; | |
| position.bestSAD = SAD; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment