Ask Your Question
0

cv2.cv.mat 64FC3 to grayscale

asked 2013-04-14 11:36:51 -0500

noSkill gravatar image

Hello. I managed to convert 64 bit float numpy array to cv material and display it. So how can i convert it to grayscale?

mat
<cvmat(type=42424016 64FC3 rows=320 cols=240 step=5760 )>
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-04-14 12:10:23 -0500

Guanta gravatar image

updated 2013-04-14 12:11:47 -0500

Take the formula: Y = 0.299*R + 0.587*G + 0.114*B , where R,G,B denote the red, green and blue channels, respectively (note: opencv loads images in BGR).

Btw: You shouldn't use the old cv-python mats, but just stick to your numpy-arrays. Each function of cv2.* takes these numpy-arrays instead of mats as input!

edit flag offensive delete link more

Comments

1

Thank you for advice, that did what it should: cv2.imshow("img",numpy.dot(array.reshape(320,240,3), [0.114,0.587,0.299]))

noSkill gravatar imagenoSkill ( 2013-04-14 13:05:09 -0500 )edit

Sweet, then you can mark the question as solved.

Guanta gravatar imageGuanta ( 2013-04-14 13:14:49 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-14 11:36:51 -0500

Seen: 242 times

Last updated: Apr 14 '13