ATG
ATG

Reputation: 752

Getting pixel values of a LAB image in opencv

I want to access the pixel values of a LAB image at a particular position.I don't want to read all the pixel values.Lets say at a position with x and y coordinates as 50 and 40 respectively. Can anyone please tell me how to do this??

Thanks

Upvotes: 0

Views: 1805

Answers (2)

Abid Rahman K
Abid Rahman K

Reputation: 52646

To get the values, just use cvGet2D and s.val[0], s.val[1], s.val[2] will give you the required intensities if it is a RGB image or just s.val[0] will suffice for greyscale.

CvScalar s;
s=cvGet2D(img,i,j);
Int value = s.val[k];

Upvotes: 1

mathematical.coffee
mathematical.coffee

Reputation: 56915

What have you tried? Have a look at the OpenCV User Guide, very near the top, the section "Accessing pixel intensity values"?

e.g.:

Vec3b intensity = img.at<Vec3b>(x, y);
Vec3f intensity = img.at<Vec3f>(x, y);

Upvotes: 0

Related Questions