#include #include "iostream" #include "time.h" #include "windows.h" using namespace std; int main() { int image[600][800]; int block[5][5]; double MSE = 0; double min = 1000000; // initial value is just a big number int BlockNumOfPixels = sizeof block; // the number of pixels for calculating MSE int Coordinates[100][2]; // the Coordination of the beginning pixels for minimmum MSEs int b = 0; // iterator of Coordinates array //generate random numbers for image pixels for (int i = 0; i < sizeof image / sizeof image[0]; i++) { for (int j = 0; j < sizeof image[0] / sizeof(int); j++) { image[i][j] = rand() % 256; } } //generate random numbers for block pixels cout<<"\n\n"<<"Block image pixels: \n\n"; for (int i = 0; i < sizeof block / sizeof block[0]; i++) { for (int j = 0; j < sizeof block[0] / sizeof(int); j++) { block[i][j] = rand() % 256; cout<= MSE) { if (min > MSE) {//new MSE found! b = 0; //add the coordination of MSE Coordinates[b][0] = i; Coordinates[b++][1] = j; } else {// same MSE found! just add the coordination Coordinates[b][0] = i; Coordinates[b++][1] = j; } min = MSE; // set the new minimmum MSE } } } cout<<"\n\n"; printf("Time taken: %.5f Second\n", (double)(clock() - tStart) / CLOCKS_PER_SEC); cout<<"\n\n"<<"MSE "<