Hi all,
I am currently using template matching technique where a mouth template with the size VS2xUS2 needs to be move pixel by pixel in a clipped region with bigger size height1xwidth1 so that correlation value for each location can be calculated. The location with highest correlation will be defined as mouth region.
Code:
//binary[height1][width1] is the array for the clipped mouth region from the input image.
/* This loop is the sliding window size VS2xUS2 to be moved along the clipped mouth region height1xwidth1 */

 for(hp=0; hp<VS2; hp++){
  for(hj=0; hj<US2; hj++){
   binary1[hp][hj] = binary[hp][hj];
  }
 }
                    
cross_correlation2(TEMPLATE2,binary1,&C2);  
// The subroutine for correlation calculation where the array of TEMPLATE2//and binary1 are needed
//TEMPLATE2 is the TEMPLATE2[VS2][US2] for mouth template,
// VS2=40;US2=110. 
//binary1[VS2][US2] is the sliding array that will be move around the clipped region with height1xwidth1.
I have no idea how to move this window(the loop above) pixel by pixel so that the cross_correlation() can calculate value for different location.

In order to make it faster and avoid to slide for each pixel, how to program so that the window will jump to 10th pixels (horizontally and vertically) after calculation from the 1st pixel position? This will save time as the calculation will only be done after 10 pixels from the previous location.

Please help if you all can understand. Thank you very much.