Guest User

Untitled

a guest
Dec 22nd, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. int nnsLoop(int M, int N, Matrix& Scene, Matrix& Waldo, int L, int highest, int xBlock, int yBlock)
  2.  
  3. {
  4.  
  5. for (int a = 0; a < M-49; a+=1) //for loop to cycle through every block in the large wally scene and perform ssd
  6. {
  7. for (int b = 0; b < N-36; b+=1)
  8. {
  9. Matrix SceneLarge = Scene.splitScene(a, b); //create a matrix to use the scene data
  10.  
  11. int ssd = 0; //creating a variable for ssd (sum of square diff)
  12. Matrix value = SceneLarge - Waldo; //find the difference
  13. Matrix value2 = value * value; //square the value
  14.  
  15. for (int m = 0; m < L; m++)
  16. {
  17.  
  18. ssd += value2._data[m];
  19. }
  20.  
  21. if (ssd < highest) //looking for the smallest value
  22. {
  23. highest = ssd;
  24. xBlock = a;
  25. yBlock = b;
  26. }
  27. }
  28. }
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment