FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6343 Discussions

adding color to grey scale video

Altera_Forum
Honored Contributor II
1,364 Views

Hello, 

I have a system that generates 8-bit grey scale video. The frame data is in ram, 8-bit grey scale 656 format. Depending upon the value of each pixel I want to be able to colorize the data. I really have no idea as to how to do that. Does anyone have any suggestions? 

Thanks
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
181 Views

If its grey scale, you cannot colourise it without the colour information, unless you are trying to colourise it for some other meaning?

0 Kudos
Altera_Forum
Honored Contributor II
181 Views

The video data represents temperature for each pixel so I want to, say for instance, if a particular pixel is above a certain temperature, make that pixel red, or a group of pixels to represent a temp gradient, how would I do that.

0 Kudos
Altera_Forum
Honored Contributor II
181 Views

what format is your video output? is it RGB or YCbCr?

0 Kudos
Altera_Forum
Honored Contributor II
181 Views

YCbCr is the current format.

0 Kudos
Altera_Forum
Honored Contributor II
181 Views

You will need to take your RGB value and convert it to YCbCr via a colour space converter, or just have a set of preset YCbCr values. Then you will need to convert it to 444 to 422 video for output (assuming you're using NTSC or PAL). 

 

Colour space conversion is a matrix transform using the following matrix: 

 

(Y ) = ( 0.299 , 0.587 , 0.114 , 0.0 ) (R) (Cb) ( -0.147 , -0.289 , 0.436 , 128.0 ).(G) (Cr) ( 0.615 , -0.515 , -0.1 , 128.0)) (B) (1)
0 Kudos
Altera_Forum
Honored Contributor II
181 Views

Ok, I must be missing something. I have YCbCr data in RAM that is 8bit grey scale. If I have YCbCr grey scale how would I colorize it I guess is the question. My output goes to an encoder that outputs NTSC analog.

0 Kudos
Altera_Forum
Honored Contributor II
181 Views

For NTSC, YCbCr is not trivial to colour as it is. It will usually be running with Y interleaved with alternating Cb and Cr. This is because the human eye only needs half of the colour information compared to luminance, so you get the following data stream: 

 

Y0 Cb0 Y1 Cr0 Y2 Cb1 Y3 Cr1 etc. 

 

This makes it very hard to colourise a 422 data stream. Its much easier to think in terms of RGB and then colour space convert it to 444 YCbCr then do the data rate conversion to make it 422 (you just take adjacent CB/Cr values and divide them by 2). 

 

see this article on wikipedia: 

http://en.wikipedia.org/wiki/ycbcr 

 

Basically, its not simple to do.
0 Kudos
Altera_Forum
Honored Contributor II
181 Views

 

--- Quote Start ---  

Hello, 

I have a system that generates 8-bit grey scale video. The frame data is in ram, 8-bit grey scale 656 format. Depending upon the value of each pixel I want to be able to colorize the data. I really have no idea as to how to do that. Does anyone have any suggestions? 

Thanks 

--- Quote End ---  

 

 

--- Quote Start ---  

The video data represents temperature for each pixel so I want to, say for instance, if a particular pixel is above a certain temperature, make that pixel red, or a group of pixels to represent a temp gradient, how would I do that.  

--- Quote End ---  

 

I understand you are trying to beautify the grey-scale image. 

A way to do this is to traverse one of the six sides of the rgb colour cube (http://http://www.mathworks.com/help/toolbox/images/color7.gif). E.g. to get images form dark-blue for grey-value 0, to fiery-red for grey-value 255, you could use the following formula: 

R <= grey_value ; 

B <= 255 - grey_value ; 

G <= 0 ; 

 

 

Or traverse the colour cube from blue to yellow: start from R=0,B=255,G=0 for grey-value 0 towards R=255,B=0,R=255 for grey-value 255. 

Of course you can think of other variations ...
0 Kudos
Reply