读取图像灰度opencv 3.0.0-dev [英] Read image grayscale opencv 3.0.0-dev
问题描述
我正在尝试直接读取黑白图像.
I am trying to read images directly as black and white.
我最近将OpenCv版本更新为3.0.0-dev,以前使用的代码不再起作用.
I recently updated my OpenCv version to 3.0.0-dev, and the code that I used before does not work anymore.
img = cv2.imread(f, cv2.CV_LOAD_IMAGE_GRAYSCALE)
适用于2.4,但不适用于新版本,因为没有字段CV_LOAD_IMAGE_GRAYSCALE
.
works fine for 2.4 but does not work for the new version, as there is no field CV_LOAD_IMAGE_GRAYSCALE
.
有什么建议吗?
注意:我知道cv2.imread(f,0)
可以工作,但是我不喜欢在代码中包含未命名的常量.
谢谢!
Note: I know that cv2.imread(f,0)
will work, but I do not like having unnamed constants in my code.
Thanks!
推荐答案
该标志已重命名为cv2.IMREAD_GRAYSCALE
.一般来说,标志现在以与它们所引用的功能有关的方式为名称加上前缀. (例如,imread
标志以IMREAD_
开头,cvtColor
标志以COLOR_
开头,等等)
The flag has been renamed to cv2.IMREAD_GRAYSCALE
. Generally speaking, flags now have names prefixed in a manner that relates to the function to which they refer. (e.g. imread
flags start with IMREAD_
, cvtColor
flags start with COLOR_
, etc.)
这篇关于读取图像灰度opencv 3.0.0-dev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!