Sunday, March 1, 2009

OpenCV get pixel value!!!!

In OpenCV, using functions to get pixel values from an image, the pixel position must be carefully set!!!!!

 

Usually, the position we got from images or mouse click is in the form (x,y).

3318775976

In the function cvGet2D(Iplimage *image, int idx0, int idx1), the first parameter is used to specify which image data to get. However, the second parameter is not corresponding to x. Instead, the second parameter is the first index of the image data array, from the above figure, the first index of the image data should be y not x!

 

That means to get the pixel data of the image at (x,y) using
cvGet2D(image, y, x);
not
cvGet2D(image, x, y);

No comments:

Post a Comment

Google+