# how to prove subtract value opencv

I need to prove pixle subtract value is right , I'm using this code :

```
subtract(image1,image2, min); //subtract image1 - image2
cout << endl << endl << "image 1 pixel : " << endl << endl;
for (int y = 0; y < 10; y++)//To loop through all the pixels 10x10
{
for (int x = 0; x < 10; x++) //4 55
{
pix_val = image1.at<uchar>(x, y);
cout << pix_val << " , ";
}
cout << endl;
}
cout << endl << endl << "image 2 pixel : " << endl << endl;
for (int x = 0; x < 10; x++)//To loop through all the pixels 10x10
{
for (int y = 0; y < 10; y++)
{
pix_val = image2.at<uchar>(x, y);
cout << pix_val << " , ";
}
cout << endl;
}
cout <<endl<<endl<< "min pixel : " << endl<<endl;
for (int x = 0; x < 10; x++)//To loop through all the pixels 10x10
{
for (int y = 0; y < 10; y++)
{
pix_val = min.at<uchar>(x, y);
cout << pix_val <<" , ";
}
cout << endl;
}
```

but the result is different

but not all value match.

Please help me, i need to prove subtract value with number.

Thank you.

you swap x and y value in first loop

to avoid the obvious problems with your for-loops (type, x,y), rather use:

I'm sorry, I'm not careful enough. Thank you for your answer. actually, i really need help, and I want to consult with you @LBerger and @berak is it okay?