Forum Discussion
Altera_Forum
Honored Contributor
15 years agoGrayScale from RGB
Hello everyone i bought the Terasic 5MP Camera to do some image processing inside but i am kinda lost in the Verilog..
For example, i have // FIFO Write Side 1
.WR1_DATA({1'b0,sCCD_G,sCCD_B}),
.WR1(sCCD_DVAL),
.WR1_ADDR(0),
.WR1_MAX_ADDR(640*480),
.WR1_LENGTH(9'h100),
.WR1_LOAD(!DLY_RST_0),
.WR1_CLK(~CCD_PIXCLK),
// FIFO Write Side 2
.WR2_DATA( {1'b0,sCCD_G,sCCD_R}),
.WR2(sCCD_DVAL),
.WR2_ADDR(22'h100000),
.WR2_MAX_ADDR(22'h100000+640*480),
.WR2_LENGTH(9'h100),
.WR2_LOAD(!DLY_RST_0),
.WR2_CLK(~CCD_PIXCLK), I can see that green red and blue channels are there and they are connected to the VGA OUTPUT. The system is working perfectly well in my DE2, however i want to transform it to a grayscale image instead of RGB I dont want to use floating points so i will use a simplification like channel = red+2*green+blue how can i do that in Verilog?? I am really lost.. thanks11 Replies
- Altera_Forum
Honored Contributor
Hi Tiffany,
You just need to implement Gray=0.299*R + 0.587*G + 0.114*B equation in verilog, Multiplications can be done with simple shift operations. I have done this long back, couldn't locate the .v file. But implementation was straightforward, needs maximum 10 lines of coding..... Feed the output from RAW2RGB into to your RGB2GRAY module... and then take the output(Y/Gray) in to the next processing unit. Y do u want to use a FIFO ?, Cheers!! Fradaric --- Quote Start --- Hi everyone! I'm using the Terasic D5M camera along with the DE0 board. I also want to convert RGB to grayscale. If I were to use the sample code above (module RGBtoY), from which module output would the RGB come from? What I mean to say is, would I use the outputs from the RAW2RGB module, as inputs to the RGBtoY module, and thus feed my output "Y" into the FIFO? Or would I use the outputs from the FIFO as inputs to the RGBtoY module? I'm really new to this, and am pretty confused, so if anyone could provide me with some guidance it would be greatly appreciated! :) Thanks, Tiffany --- Quote End ---