This project demonstrates a custom image filtering application in C. The code loads a grayscale PNG image, applies a convolutional filter, measures the filtering performance, and outputs the filtered image. Key metrics such as memory bandwidth and pixel rendering speed are displayed in real-time. The project leverages cycle counting, low-level memory manipulation, and the libpng library for image handling.
- Convolutional Image Filtering: Applies a 3x3 kernel to enhance edges in grayscale images.
- Performance Metrics: Measures execution time, memory throughput, and rendering speed for benchmarking.
- File I/O with PNG: Utilizes
libpngto read and write grayscale PNG files. - Cycle-Based Timing: Uses processor cycle counting to calculate filter execution time.
- C Compiler (e.g.,
gcc) - libpng: PNG library for C (
sudo apt-get install libpng-devon Debian-based systems) - GNU Make: For compiling the project
-
Clone the Repository:
git clone https://github.com/ksemk/imageConvolution cd imageConvolution -
Build the Project: Compile the program by running:
make
The
makefileis configured to handle the compilation process automatically.
Run the executable with a grayscale PNG file as input:
./program input.pngThis command performs the following steps:
- Loads the input image
- Applies the convolutional filter to enhance edges
- Measures performance metrics such as execution time, memory throughput, and rendering speed
- Outputs the processed image as
out.png
./program sample.png- Console Output: Displays performance data including cycle count, execution time, memory bandwidth, and rendering speed.
- Filtered Image: The resulting image is saved as
out.pngin the current directory.
The measure_performance function calculates metrics based on CPU cycles to assess filtering performance:
- Cycles: Number of CPU cycles used for filtering
- Execution Time: Time taken to apply the filter, calculated from cycles and CPU frequency
- Memory Bandwidth: Average data throughput in GB/s
- Rendering Speed: Pixel processing speed in Mpx/s
- filter: Applies a convolutional kernel to each pixel to highlight image edges.
- measure_performance: Measures performance metrics.
- main: Manages file I/O, initializes
libpng, and coordinates the filtering and performance measurement functions.
This project uses the following files:
program: Main executable filemakefile: Automates compilationtimestamp64.s: Assembly code to count CPU cyclesLICENSE: License file for open-source usage
For any inquiries, support requests, or if you're interested in collaborating, please don't hesitate to reach out:
- Email: kyrylo.semenchenko@gmail.com
- GitHub: Visit my GitHub profile
- LinkedIn: Connect with me on LinkedIn
I look forward to hearing from you!
This project is licensed under the MIT License - see the LICENSE file for details.