Skip to content

aliemo/hsv-mask-tool

Repository files navigation

HSV Mask Tool

A simple Python GUI tool for visualizing and creating HSV masks on images. Adjust Hue, Saturation, and Value ranges, save masked images, and export mask settings to CSV.

Features

  • Load a folder of images (.jpg, .png, .jpeg, .bmp).
  • Default folder: sampledata (loaded automatically if exists).
  • Adjust HSV ranges with interactive sliders.
  • Toggle mask background between black and white.
  • Navigate images with Prev/Next buttons.
  • Save mask settings in memory and export to CSV.
  • Save masked images with _masked suffix.
  • Application window icon support.

Requirements

  • Python 3.10+
  • PyQt5
  • OpenCV (opencv-python-headless)
  • NumPy

Install dependencies:

pip install -r requirements.txt

Project Structure

HSVMaskTool/
│
├─ HSVMaskTool.py        # Main application
├─ sampledata/           # Default images (optional)
├─ res/
│  └─ icons/
│     └─ icon.png        # Application icon
├─ README.md
└─ requirements.txt

Usage

  1. Option 1: Run executable version
HSVMaskTool
  1. Option 2: Run in python
python HSVMaskTool.py
  • Load Default Images: If a folder named sampledata exists in the project directory, it will be loaded automatically.

  • Load Another Folder: Click the Load Folder button to choose a different folder with images.

  • Save Mask Settings:

    • Click Save Mask to save the current HSV settings for the displayed image.
    • Click Export CSV to save all saved mask settings to a CSV file.
  • Save Masked Image Click Save Masked Image to save the masked image with the original filename plus _masked.

Notes

  • Masked images and CSV files are saved in the current working directory.
  • Ensure the sampledata folder exists if you want default images to load.

Developer Guide

Packaging with PyInstaller

pyinstaller HSVMaskTool.spec
  • Windows: .exe executable
  • Unix: binary executable
  1. Make sure res/icons/icon.png and sampledata folder are included in the .spec file as datas.
  2. For Windows, convert icon.png to .ico for proper .exe icon display.

About

A simple Python GUI tool for visualizing and creating HSV masks on images.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages