Image Processing Toolbox in Verilog using Basys3 FPGA
Loading README and project media…
(ES 203: Digital Systems Project, Prof. Joycee Mekie, IITGN)
This Image Processing Toolbox is a project developed for the Basys3 FPGA, primarily using Verilog for hardware description and Python for image-to-binary conversion tasks. It enables users to perform various image processing operations, particularly convolution-based techniques. The workflow involves converting input images to a binary format (.coe files) via Python scripts, loading these files into the FPGA's Block RAM, processing the image based on user selection, and then either writing the results back to a PC or displaying them in real-time on a VGA monitor. Development and FPGA implementation are carried out using the Xilinx Vivado software suite.
The toolbox offers a range of image processing functions, selectable via the sel_module in the Verilog code. Some functions also allow parameter adjustments (e.g., brightness) using the val input. The available operations include:
RGB2Gray (0000):

Increase brightness (0001):

Decrease brightness (0010):

Color Inversion (0011):

Red Filter (0100):

Blue Filter (0101):

Green Filter (0110):

Original Image (0111):

Average Blurring (1000):

Sobel Edge Detection (1001):

Edge Detection (1010):

Motion Blurring xy (1011):

Emboss (1100):

This project offers two distinct methods for performing image processing operations:
coe_generator.py) converts this image into a .coe (Coefficient) file format.BIPT/ and Blurring/ folders.Final Project/VGA_1/ folder.To use this toolbox, you will need:
git clone https://github.com/Gowtham1729/Image-Processing-Toolbox.git
cd Image-Processing-Toolbox
pip install opencv-python numpy
Several Python scripts convert input images into the .coe (Coefficient) file format, which Verilog modules use.
coe_generator.py: For basic image processing. Converts an image into a list of binary numbers (pixel color values). Suitable for operations processing pixels individually (e.g., brightness adjustment, color inversion).kernel_coe_generator.py: For convolution-based operations (e.g., blurring, edge detection). Converts an image to grayscale and arranges pixel data so neighboring pixels needed for kernel application are grouped in the .coe file.parallel_image_generator.py: For the final FPGA project. Combines the output of kernel_coe_generator.py (grayscale, kernel-formatted) with original color pixel values into a single .coe file. This enables the FPGA design to perform both operation types.General Python Script Usage:
Execute scripts from your terminal, providing the input image path. They typically output a .coe file.
Note: The Python scripts (e.g., coe_generator.py) currently use hardcoded input and output file paths within the script itself. You will need to modify these paths directly in the Python files to process your specific images and define output locations. Future enhancements could involve adding command-line argument support to these scripts.
Process images using Verilog simulations on your PC.
coe_generator.py for basic operations, or kernel_coe_generator.py for specific kernel tests) to convert your image.BIPT/ (basic operations) or Blurring/ (convolution operations) folders to point to your generated .coe file..coe file, process data, and write the output to a new image file (often .bmp) on your PC.Run image processing operations directly on the Basys3 FPGA, with output to a VGA monitor.
kernel_coe_generator.py with your input image.parallel_image_generator.py using the output from the previous step and the original image to create the final .coe file for the FPGA.Final Project/VGA_1/ design, manually initialize the Block RAM (BRAM) with the generated .coe file's contents. This is typically done via the Vivado GUI by associating the .coe file with the BRAM IP core.BIPT/: Verilog modules for PC-based simulation of basic image processing operations (e.g., brightness, grayscale).Blurring/: Verilog modules for PC-based simulation of convolution-based operations (e.g., blur filters).Final Project/: The complete Verilog project for Basys3 FPGA implementation, including VGA output and real-time operation selection.
Final Project/VGA_1/: Contains the specific VGA controller and top-level module for FPGA.images/: Sample input images and example output images referenced in this README.*.py (root directory): Python scripts for converting images to .coe files (e.g., coe_generator.py, kernel_coe_generator.py, parallel_image_generator.py).This section briefly overviews key technical components.
The FPGA's Block RAM stores image data in binary format (from a .coe file). Python scripts convert images into this format, where each line typically represents pixel data. For convolution operations needing simultaneous access to multiple pixels (e.g., a 3x3 kernel), the Python scripts structure the .coe file to group necessary neighboring pixel data. This allows Verilog modules to efficiently access required BRAM data.
A Verilog-implemented VGA controller module displays the processed image on a standard VGA monitor. It generates horizontal sync (hsync) and vertical sync (vsync) signals, plus RGB color data, typically for a 480p (640x480 pixels) resolution at 60Hz. The controller reads pixel data from BRAM and translates it into analog signals for the VGA standard.
A .coe file is a Xilinx-specific ASCII text file for initializing Block RAMs or ROMs in FPGA designs. It usually includes a header specifying the data's radix (binary or hexadecimal), followed by a vector of data values. In this project, these values represent image pixel data.
For more details, see the COE File Syntax in the Xilinx documentation.
Contributions are welcome! If you have improvements or bug fixes, please fork the repository, make your changes, and submit a pull request.
This project is licensed under the Apache License 2.0. See the LICENSE file for full details.
If you find this repository helpful, please consider giving it a star on GitHub! ⭐
Sharpen (1101):

Motion Blur in x direction (1110):

Gaussian Blur (1111):
