Electronic – How do i read the RGB values of an image in Verilog from a hex file generated in Matlab for processing

MATLABmodelsimverilog

I have used Matlab to generate hex file for an image (1200 * 900 resolution). The hex file is like enter image description here

There are such 3240000 rows. How do i read this in verilog to performing some processing (filtering out areas where R,G,B values are in some desired range) and then write it into text so that Matlab could return how the image looks like after processing.
Any lead on such image processing is much appreciated.

Best Answer

The image is of resolution 1200x900. It means it contains 1080000 pixels. Each pixel is represented by 24-bit RGB data in the hex file generated by MATLAB. 8 bits to represent intensities of R, G and B components in each pixel. So each line represents R/G/B component. Three lines represent a pixel, so total of 3240000 lines represent the complete image.

If you want to process this image in Verilog, for example manipulate brightness/change hue of pixels etc, you simply have to change R/G/B values of each pixel. For eg: if you increase the RGB value uniformly, the pixel becomes brighter, decrease to make the pixel darker. Increase R/G to make the pixel warmer, increase G/B make the pixel cooler. etc

What you need to do is write a Verilog code to read line by line from the file in hex format, update the R/G/B values as per how you need to process that pixel (there must be image processing algorithms based on what kind of processing you need to do to the pixels), and write the new hex value of R/G/B to a new file. You have the "processed image" in new hex file finally. Give that to MATLAB.