函数读取CV_16UC1的png图片

opencv imread 函数读取CV_16UC1的png图片

opencv 2.4.11中imread读取图片有三种方式:

  • CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
  • CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one
  • CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format

如果待读取的png图片是灰度图,而且是16位的,那么应该选用CV_LOAD_IMAGE_UNCHANGED,用Mat类型保存。

例如:

Mat img = imread("depth.png",CV_LOAD_IMAGE_UNCHANGED);

那么img就是一个CV_16UC1类型的数据,访问像素(i,j)

img.at<ushort>(i,j)即可。

猜你喜欢

转载自blog.csdn.net/CVAIDL/article/details/82854341