Ask Your Question
0

Trasforme GRAY2RGB

asked 2014-04-30 10:08:55 -0600

hafidhfhh gravatar image

plzzzz hel

plzz help me how to transforme image grayscale to RGB

function cvtColor(.,.,GRAY2RGB); don't work pfff plz help me how to do this in opencv C++ visuel studio 2010

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-04-30 13:49:23 -0600

You cant simply convert gray to rgb. You need to make a mask to do it. The computer needs to know what are the colors of the image in RGB scale to convert.

edit flag offensive delete link more
1

answered 2014-05-01 02:29:36 -0600

I do think both suggestions contain wrong information. To make it a little more clear look at the link that @FLY provided right here. If you go down to the cvtColor function and to the grayscale to rgb conversion you will see the following statement.

Gray to RGB[A]: R <-- Y, G <-- Y, B <-- Y, A <-- \max(ChannelRange)

Here comes in play directly what @Allyson Martins suggested. When you got a grayscale image you only have intensity values from 0 - 255 of each pixel. You have basically no idea how the relation of green, blue and red is in that specific pixel.

So you either have to

  1. Define a relation between the channels and use that to backproject the colors
  2. Or you do like openCV and take the same intensity values for each channel. This will look like a grayscale image but in fact it is not! You changed from the 8UC1 type to 8UC3 type thus having three color values, just all the same weight, resulting in a grayisch colored color image.
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-04-30 10:08:55 -0600

Seen: 2,896 times

Last updated: May 01 '14