Image Processing Toolkit

A beginner-friendly toolkit for image processing with OpenCV

Project Overview

This project provides a beginner-friendly toolkit for image processing with OpenCV, designed This project offers an easy-to-use toolkit for image processing with OpenCV. It simplifies tasks like loading, saving, and displaying images, so you can focus on experimenting with image transformations. The results are shown instantly on a live webpage, letting you see changes in real time without needing to juggle different tools or folders.

Key Features

Functions

ImageProcessor

The process_image function is the core utility for applying custom image processing functions to an input image. It simplifies the workflow by handling file management, processing, and optional output customization.

from src.ImageProcessor.ProcessImage import process_image

def process_image(file_path: str, file_name: str, function_name="random", process_fn=None, save_as_jpeg=False) -> bool:
  • file_path (str): The directory path where the input image is located.
    • Example: "./assets/input_images/".
  • file_name (str): The name of the input image file (including the extension).
    • Example: "example.png"
  • function_name (str): Name of the function, which specifies the folder where the output images will be saved. By default, the folder is named 'random'.
    • Default: "random"
    • Example: "invert"
  • process_fn (callable): A Python function that defines the image processing logic. The function should accept an input image and return the processed image.
    • Example:
      def invert_colors(image):
          return cv2.bitwise_not(image)
  • save_as_jpeg (bool): Save output as JPG instead of origin format

ProcessResultsHTML

The process_results function is a utility for consolidating processed images and displaying them in an organized HTML file. It takes the processed image files from a source directory, generates an HTML report, and saves the report to the specified output directory.

from src.ProcessResultsHTML import process_results

def process_results(src="src", output_dir="out", output_file="results.html"):
  • src (str): The source directory where processed images are stored.
    • Example: If your processed images are in ./cache/images/, set src="cache/images"
  • output_dir (str): The directory where the resulting HTML file will be saved.
    • Example: "./reports/"
  • output_file (str): The name of the HTML file to generate.
    • Example: "processed_images_report.html"

Project Structure

PROJECT/
│
├── .devcontainer/           # DevContainer configuration for remote or containerized development
├── .env                     # Environment variables for the project
├── .github/                 # GitHub-specific workflows and configurations
├── assets/                  # Input media files (images and videos)
│   └── input_images/        # Add input images or videos here
│
├── cache/                   # Stores processed images (output files)
│   └── images/              # Automatically generated processed images
│
├── ideas/                   # Placeholder for project-related ideas or future plans
├── js/                      # JavaScript files (if applicable for the frontend)
├── log/                     # Logs generated during runtime
├── out/                     # Contains final output files (like reports or results)
│   └── results.html         # Auto-generated HTML file showing processed results
│
├── plugins/                 # Plugins or helper assets (e.g., images, external scripts)
│   └── results.png          # Example image used in the documentation
│
├── src/                     # Source code directory
│   ├── ImageProcessor/      # Core image processing functionality
│   │   ├── __init__.py      # Package initialization
│   │   └── functions.py     # Main functions for processing images
│   └── ProcessResultsHTML.py # Generates HTML reports for processed images
│
├── templates/               # HTML or Jinja templates (if applicable)
├── testsuml/                # Testing utilities or scripts
├── uml/                     # UML diagrams or architecture documentation
│
├── .editorconfig            # Editor configuration for consistent coding styles
├── .gitignore               # Specifies files and directories ignored by Git
├── .gitpod.Dockerfile       # Dockerfile for Gitpod development environment
├── .gitpod.yml              # Gitpod configuration file
├── .prettierrc              # Configuration for Prettier code formatting
├── CONTRIBUTING.md          # Guidelines for contributing to the project
├── LICENSE.txt              # License information
├── main.py                  # Main entry point for the application
├── README.md                # Project documentation
├── requirements.txt         # Python dependencies
├── SECURITY.md              # Security guidelines
├── setup.py                 # Python package setup

The structure includes directories for input files (assets/input_images/), processed outputs (cache/images/), and reports (out/results.html). Core logic resides in src/, featuring modules for image processing (ImageProcessor/functions.py) and HTML report generation (ProcessResultsHTML.py). Configurations like .editorconfig ensure consistent coding styles, while .gitpod.Dockerfile and .gitpod.yml enable streamlined containerized development. The project also includes detailed documentation (README.md, CONTRIBUTING.md) and excludes temporary files using .gitignore.

visualize results with original images for easy debugging