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

Software Implementation Platform


The software implementation consists of converting a known standard format to raw pixel data, sending the pixels to FPGA via the Parallel port, retrieving the raw pixels from FPGA and finally converting it back to a standard format. The process of image extraction, transmission and reception of the extracted data and converting back the processed data into the image is done using softwares that run on the GNU/Linux platform. Using GNU/Linux has the advantage of being able to access the computer parallel port both at the user level and at a higher or kernel level. This is not the case with other operating systems like Windows. A problem that plagues Windows NT/2000/XP, is it's strict control over I/O ports. Unlike Windows 95 & 98, Windows NT/2000/XP will cause an exception (Privileged Instruction) if an attempt is made to access an I/O port that your program is not privileged to access. In GNU/Linux environment, for a user-space program there are two options: use PPDEV generic parallel port driver via ioctl functions, or use direct low level port IO through the inb/outb family of macros provided with the GNU C library. The latter option was used.
The image manipulation is done using programs written in C (with libraries libjpeg,libpng). The software were compiled and executed on Debian based Ubuntu and Fedora.

more »

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 »
Tag Cloud 74LS33 74LS641 Architecture BMP BMP Linux Canny Circuit DB25 Device Utilization Digital Image Processing Edge Detection FPGA Fedora GCC Image Manipulation Imtools JPEG Laplacian Linux Memory Modules Octal Transciever OpenGL PC Interface PNG Parallel Port Prewitt RAM Roberts Sobel Spartan 3 System Ubuntu VLSI Verilog XC3S400 Xilinx libjpeg libpng