i have the following code which compares two images and outputs how many pixels are different. I'm trying to figure out how to make it output the x and y coordinates of the pixels. Anyone have an idea?
public int count2;
public Boolean flag;
private void button1_Click(object sender, EventArgs e)
{
string img1_ref, img2_ref;
//this image is 10x10
Bitmap img1 = Properties.Resources.black;
//this image is a screenshot
Bitmap img2 = Properties.Resources.bigimg;
for (int i = 0; i < img1.Width; i++)
{
for (int j = 0; j < img1.Height; j++)
{
img1_ref = img1.GetPixel(i, j).ToString();
img2_ref = img2.GetPixel(i, j).ToString();
if (img1_ref != img2_ref)
{
count2++;
flag = false;
break;
}
}
}
if (flag == false)
MessageBox.Show(count2 + " wrong pixels found");
}
these are the images, and the small black square should be found in the middleish of the big image: