Edge Detection in FPGA using Sobel Operator
Edge Detection in FPGA using Sobel Operator

The RAW Image Format


The hardware implementation on FPGA requires raw pixel information. Therefore we have to convert a standard image format (such as JPEG, PNG, and BMP) to a raw image. In this format, we use 8 bits to represent a pixel, i.e, 00000000 represents a pixel which is completely black, while 11111111 represents a pixel which is completely white. The extracted image is represented as a 2-dimensional array of integer values ranging from 0 to 255 corresponding to the individual pixels of the image. For colour images the raw data requires three 8-bit data corresponding to each of the primary colours Red, Green and Blue and will have to be processed one by one in the FPGA. The source image is converted from encodings like JPEG,PNG using codes written in GNU C. BMP is a relatively raw format, but it is still converted to our plain text readable format after parsing the Bitmap Headers The file format The file is a plain text file (not binary, for readability) format used for our raw image format is as follows:
Width Height Number of Colours(1 or 3) Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data .... . . . Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data Pixel Data
Pixel Data is a 3 digit integer < 255 if Number of Colours is 1 ie Monochrome or 3, 3 digit number < 255. Eg: 5x4 monochrome
5 4 1 168 168 168 183 183 168 168 168 183 183 168 168 168 183 183 168 168 168 183 183
2x2 TriColour Image
2 2 3 168 168 168 183 183 200 168 168 168 183 183 200

more »

Converting JPEG,BMP,PNG Files to RAW Format


Conversion of the various image formats are done with the help of the imtools program written for linux in GNU C, for more details check out the imtools section. The imtools program can convert formats to and from raw format and other common formats, in addition convert images from jpeg to bmp, bmp to jpeg in linux using the libjpeg library. The program can also display images on the screen using OpenGL library. The software can also do a software edge detection on sobel, prewitt or roberts or any custom edge detection algorithm by specifying its own custom masks.
Usage: ./imtools source.(jpg|png|bmp) COPY destination.txt Example: ./imtools images/source.jpg COPY images/destination.txt

more »