Skip to content

IgorGreenIGM/IO_IMAGE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IO_IMAGE: C++ Computer Vision Library

Language License

IO_IMAGE is an image processing and computer vision library written entirely in C++17. Its key feature is having zero dependencies on third-party imaging libraries (like libpng or OpenCV) for PNG file handling. It implements its own PNG reader and writer from scratch, along with a collection of computer vision algorithms.

This project aims to provide a deep understanding of the low-level mechanics of image processing, from file format management to the implementation of fundamental algorithms.

Table of Contents

  1. Features
  2. Prerequisites
  3. Building from Source
  4. Usage
  5. Examples
  6. Author
  7. License

✨ Features

The IO_IMAGE library offers a diverse set of tools for image manipulation.

PNG File Handling

  • Read and write PNG files without external dependencies.
  • Handling of critical (IHDR, IDAT, IEND) and ancillary (pHYs) chunks.
  • Implementation of filter algorithms (Sub, Up, Average, Paeth) and compression/decompression via the bundled zlib.

Color and Pixel Manipulation

  • Color space conversion (RGB, HSL, HSV).
  • Color mode conversion (RGB to Grayscale, RGB to Binary).
  • Color channel extraction (Red, Green, Blue).
  • Colorization via Look-Up Table (LUT).

Image Processing Algorithms

  • Image segmentation (Thresholding and Otsu's method).
  • Dominant color detection (Histogram-based and K-Means clustering).
  • Blur filters (Mean blur and Gaussian blur).
  • Edge detection.

Image Analysis

  • Histogram computation and plotting.
  • Partial multi-threading support for performance optimization.

📋 Prerequisites

Before building the project, make sure you have the following tools and libraries installed on your system.

  • A C++17 compliant compiler (GCC, Clang, or MinGW for Windows).
  • Make (for Unix-like systems).
  • Development libraries for:
    • zlib
    • OpenGL
    • GLUT

Dependency Installation Instructions

  • On Debian / Ubuntu:
    sudo apt-get update
    sudo apt-get install build-essential libz-dev libglu1-mesa-dev freeglut3-dev
  • On macOS (with Homebrew):
    brew install gcc zlib freeglut
  • On Windows: The easiest environment is using MinGW-w64. You can install it via MSYS2 and add the necessary packages. Ensure the MinGW bin directory is added to your system's PATH.

⚙️ Building from Source

First, clone the repository:

git clone https://github.com/IgorGreenIGM/IO_IMAGE
cd IO_IMAGE

On Linux / macOS

The project can be easily built using the provided Makefile.

  1. Open a terminal in the project's root directory.
  2. Run the make command to build the project:
    make
  3. The executable will be generated at bin/output.

To clean up object files and the executable, you can use:

make clean    # Removes object files (*.o)
make mrproper # Removes object files and the executable

On Windows

The compile.bat and link.bat batch scripts are provided for 32-bit compilation with a MinGW-like toolchain.

  1. Open a Command Prompt (cmd) or PowerShell terminal in the project's root directory.
  2. Step 1: Compile source files Run the compile.bat script. It will compile the .cpp source files into object files (.o) and move them to the bin/link directory.
    compile.bat
  3. Step 2: Link object files Run the link.bat script. It will link the object files to create the final executable.
    link.bat
  4. The executable will be generated at bin\output.exe.

🚀 Usage

The main executable is a demo program that applies a few filters to a source image.

  1. Prepare the input image: Place a PNG image named origin.png in the project's root directory. The program will perform its operations on this image.

  2. Run the executable:

    • On Linux / macOS:
      ./bin/output
    • On Windows:
      .\bin\output.exe
  3. Check the results: The program will generate two new images in the root directory:

    • gray.png: A grayscale version of the original image.
    • blurred.png: A blurred version of the original image.

📁 Examples

The /Examples directory contains visual results showcasing the library's core features. Here is a preview of the algorithms in action.

Binarization (Otsu's Method)

Otsu's method segments an image into black and white by finding an optimal threshold to separate the foreground from the background.

Original Grayscale Binarized Result
Original Otsu Grayscale Otsu Binarised Otsu

LUT (Look-Up Table) Colorization

A grayscale image is recolored using a color palette (lut.png) from another image.

Original Palette (LUT) Colorized Result
Original LUT Palette LUT Result LUT

Dominant Color Detection (K-Means)

The K-Means algorithm extracts the most representative colors from the original image to create a palette, which is then used for recolorization.

Original Extracted Palette (KMeans) Result
Original K-Means Palette K-Means Result K-Means

Edge Detection

An edge detection algorithm is applied to extract shapes and objects from the image.

Original Edges Detected
Original Edges Result Edges

Color Overscreening

The two most frequent colors in the image are isolated and highlighted, while the rest of the image is converted to grayscale.

Original Overscreened Result
Original Overscreen Result Overscreen

Grayscale Conversion

Convert RGB/HSL color spaces values to Grayscale images

Original Grayscale
Original Image Converted

✍️ Author

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.