Reputation: 77
I have a 640x480 image which I need to display on VGA. I have to read that image through matlab imread
command, than convert that RGB imformation into binary and than use that binary data in FPGA (Nexys 4 Artix 7 board) to show image on VGA. But the problem is that VGA requires 12 bit RGB and MATLAB reads image in 24 bit RGB. How can I compress that image in 12 bit RGB?
Upvotes: 0
Views: 2760
Reputation: 66
Are you sure that you have a 12 bit VGA? Usually 24 bit RGB means 8 bits for red, 8 for green and 8 for blue, which leads to a color resolution of 2^24 = 16.8 mio colors
Downscaling the color space to 12 bit would lead to a color resolution of 4096 colors which is pretty weak for modern monitor devices.
If you really want to downscale from 24 to 12 bit, it depends on the color encoding you have to do. Most common is to use the MSBs of the three colors which leads to a bit mapping like
RGB12 = RGB24[23:20] & RGB24[15:12] & RGB24[7:4]
Edit: Just have seen in the Nexys schematic that you really have a 12 bit VGA output. The mentioned bit mapping should be valid. You can do this mapping using VHDL
...
signal RGB24 : std_logic_vector(23 downto 0);
signal RGB12 : std_logic_vector(11 downto 0);
...
RGB12 <= RGB24(23 downto 20) & RGB24(15 downto 12) & RGB24(7 downto 4);
Upvotes: 2