GrayScale Vs YUV comparaison

asked 2015-03-19 03:47:28 -0600

begueradj gravatar image

updated 2015-03-19 04:18:21 -0600

berak gravatar image

In some comments on previous questions, people told me that Y value of a YUV image converted using:

image_in_yuv=cv2.cvtColor(image_in_bgr,cv2.COLOR_BGR2YUV)

is the same as the L value of the same image in its grayscale color space converted using

image_in_grayscale=cv2.imred('image.png',cv2.IMREAD_GRAYSCALE)

I wonder how is this true ? because on my side when I run for example:

print image_in_yuv[200,200,0] # Y will be printed
print image_in_grayscale[200,200] # L will be printed

I get different values of Y and L for the pixel (200,200)

So did I misunderstand something ?

edit retag flag offensive close merge delete

Comments

Just tested it and seems you are right, so might be a bug, but I know too less about color-spaces (esp. about YUV which seems to have different standards etc.)

Guanta gravatar imageGuanta ( 2015-03-19 04:42:26 -0600 )edit

Are you using OpenCV3? Have you tried COLOR_RGB2YUV? Or read it color and convert to gray? Verify and if there is a bug, you shall mention it for correction. On wiki, they say that "luminance is denoted by Y"

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-19 07:38:18 -0600 )edit

@thdrksdfthmn: I have tried both variants

Guanta gravatar imageGuanta ( 2015-03-19 11:09:09 -0600 )edit

Y and L are definitely not the same at all. May be in meanings, but not precisely in practice.

begueradj gravatar imagebegueradj ( 2015-03-19 11:11:37 -0600 )edit

Definitely a bug, this should be fixed...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-20 03:47:31 -0600 )edit

@thdrksdfthmn this can not be a bug at all.

begueradj gravatar imagebegueradj ( 2015-03-20 05:45:51 -0600 )edit

The theory says that Y is luminance and gray-level is luminance (see wiki); so y != gray-level is a bug

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-20 07:43:22 -0600 )edit