I was trying to draw a gradient image with opencv's step But the result was wrong. Could someone give me some hints ? thanks!
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat img;
Scalar a = 0;
img = Mat(32, 32, CV_8UC1, a);
unsigned char *p;
for(int i=0; i<img.rows; i++)
{
p = img.data + i*img.step[0];
for(int j=0; j<img.cols; j++, p++)
{
*p = j;
}
}
imwrite("gradient.png", img);
return 0;
}