Ask Your Question

Revision history [back]

why load an image with input 0 gives a different result that converting the same image with input 1 to grey scale with opencv crtcolor method?

In Open CV with python, I wrote the following script:

import numpy as np

import cv2

'''Compare imread( 'detect_blob.png',0) with imread('detect_blob.png',1) and convert to gray scale'''

Method 1

img = cv2.imread('detect_blob.png',0)

width = img.shape[1]

cv2.imshow("Image_Use0",img)

cv2.moveWindow("Image_Use0",0,0)

Method 2

gray = cv2.cvtColor(cv2.imread('detect_blob.png',1), cv2.COLOR_RGB2GRAY)

cv2.imshow("mage_cvtColor",gray)

cv2.moveWindow("Image_cvtColor",width,0)

Note:

'''When display, Method 1 has lighter grays than the Method 2,

does this means that this two conversion of a RGB image to Gray Scale image, handle the conversion in different ways?

If so, why, and should I learn more about it?'''

Thank you so much

cv2.waitKey(0) cv2.destoryAllWindows()