简体   繁体   中英

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

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];

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

eg:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM