1 | initial version |
Swapping the two for
loops should work:
for (int x=0;x< frame_gray.cols;x+=1){
for( int y=0; y< frame_gray.rows; y++){
cout<<"pixel at X="<<x<<" and y="<<y<<" is: "<<frame_gray.at<uchar>(y,x);
if (frame_gray.at<uchar>(y,x)==0)
{ cout << " (black)" << endl;}
else
{ cout << " (white)" << endl;}
//waitKey(0);
}
cout << "new pixel column: "<<x << endl;
}
In the meantime, as long as it's possible, you should use line-by-line processing and line pointers. It's faster than direct element access with image.at<type>(y,x)
.