Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

threshold results to a 1channel, binary image. you probably got the order of operations wrong, it should be:

img = cv2.imread('bookpage.jpg')  
grayscaled = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
retval, threshold = cv2.threshold(img, 12, 255, cv2.THRESH_BINARY)

threshold threshold() results to a 1channel, binary image. you probably got the order of operations wrong, it should be:

img = cv2.imread('bookpage.jpg')  
grayscaled = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
retval, threshold = cv2.threshold(img, 12, 255, cv2.THRESH_BINARY)

threshold() results to a 1channel, binary image. you probably got noobs NEVER check, if the order of operations wrong, image was actually read...

it should be:

img = cv2.imread('bookpage.jpg') cv2.imread('bookpage.jpg')
if img != None: # wrong image path
 
grayscaled = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
retval, threshold = cv2.threshold(img, 12, 255, cv2.THRESH_BINARY)
    # any other operation