Read image grayscale opencv 3.0.0-dev Read image grayscale opencv 3.0.0-dev python python

Read image grayscale opencv 3.0.0-dev


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.)


Try this it works for me

import cv2im_gray = cv2.imread('gray_image.png', cv2.IMREAD_GRAYSCALE)thresh = 127im_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1]cv2.imwrite('blackwhite.png', im_bw)


Try this, it works for me everytime

import cv2gray_img = cv2.imread('img.png', 0)cv2.imshow(gray_img)