This project demonstrates image convolution using assembly language, applying various filters like sharpen, blur, and edge detection through kernel manipulation. The goal is to showcase how assembly-level operations can handle image processing tasks efficiently.
The core of this project involves convolution operations, which are widely used in image processing for modifying pixel values based on neighboring pixels. Convolution is implemented using different kernels (or filters) to achieve various effects on images.
-
Convolution Filters: Implements multiple convolution filters, including:
- Sharpen Filter: Enhances the edges of objects in the image.
- Blur Filter: Smooths the image by reducing noise and detail.
- Edge Detection: Detects the boundaries within an image using a ridge filter.
-
Assembly Code: This project is written in assembly language, focusing on:
- Low-level optimization: Assembly allows fine control over hardware, ensuring efficient memory usage and performance.
- Matrix Operations: Applies a 3x3 kernel (or custom sizes like 5x5) to the image matrix to process each pixel.
-
Performance Focused: The project aims at providing fast computation by leveraging assembly's direct control over system resources.
- Kernel Definitions: Located in
cross_normal.asm
andcross_parallel.asm
, these files define the various filters. - Image Processing: Assembly routines process input images pixel by pixel using the defined kernels.
- Matrix Transpose: A utility for efficient matrix manipulation during convolution.
- Test Images: Example images are provided to demonstrate the effects of each filter.
- Input: The program takes an input image, reads it as a matrix of pixels.
- Kernel Application: A 3x3 convolution kernel is applied to the image matrix.
- Output: The transformed image is written out after the convolution operation.
- Sharpen Kernel Example:
0 -1 0
-1 5 -1
0 -1 0
Below are examples of the images after applying various convolution filters.
This image was processed using the sharpen filter to enhance edges and details.
This image demonstrates the blur filter, which smooths the image by reducing noise.
The edge detection filter highlights the boundaries within the image.
Testing different filters shows significant performance benefits of assembly-level optimization over high-level languages. The time complexity for processing increases with image size, but assembly ensures minimal overhead.
Filter | Average Time (s) |
---|---|
Sharpen | 0.378 |
Blur | 0.387 |
Edge Detection | 0.453 |
- Clone the repository:
git clone https://github.com/kasrahmi/Convolution_Image.git
- Compile the assembly code using NASM or your preferred assembler:
nasm -f elf64 cross_normal.asm
- Run the compiled code with the input image:
./convolution input_image.bmp
- Implement more complex filters (e.g., Gaussian blur).
- Extend kernel sizes for higher resolution effects.
- Add support for colored images (currently operates on grayscale).