1 | initial version |
For each image type you have the according data type: uchar
for CV_8U
, Vec3b
for CV_8UC3
, ushort
for CV_16U
, int
for CV_32S
, float
for CV_32F
etc.
Always use the according data type:
Mat image(100,100,CV_8UC1);
uchar pixel=image.at<uchar>(10,10);
(you don't need a second type cast: pixel=(uchar)img.at<uchar>(10,10);
)
The pixel access in OpenCV is quite well explained in the docs.
It's also good to learn the pointer (line) access.