Code Monkey home page Code Monkey logo

image-contrast-analyser's Introduction

Image Classification based on contrast, luminosity or color

Before classification and after image classification

Process directory of images, analyze their attributes (luminosity, color, and standard deviation), then COPY (or MOVE) and categorize them into subdirectories based on those attributes.

  • Standard Deviation (for contrast)
  • Luminosity (Based on the most dominant color 0 - 255)
  • HSL (mainly for hue)

Benefits:

Ability to categorise images based on e.g. singular luminosity value, color (e..g: show only red images), hue, luminosity intensity. If image has certain contrast to luma to color ratio it could be possible to say how likely it is a picture of a dress or a tshirt.

Some of the use-case examples:

  1. Find all pink images: Look in the hue/320-359/ directory for light pink and hue/0-39/ for darker pinks.
  2. Identify black and white images: Check the std/0-39/ directory for images with low standard deviation.
  3. Separate dark and light images: Use the Luminosity folders to distinguish between dark (0-74) and light (175-249) images.
  4. Find high-contrast images: Look in the higher std/ folders (e.g., 120-159) for images with high contrast.
  5. Group images by color temperature: Warm colors will be in hue/0-39/ and hue/320-359/, cool colors in hue/180-239/.
  6. Identify monochromatic images: Look for images that appear in low std/ folders and have consistent hue categorization.
  7. Separate vivid and muted images: Vivid images will likely have higher std values, while muted images will have lower std values.
  8. Identify images with similar color palettes: Group images that appear in the same hue/ and std/ categories.
  9. Find "golden hour" photos: Look for images in the hue/40-79/ (orange/golden) category with medium to high luminosity.

3 scripts are provided:

  • image_classification_by_STD_Luminosity_HUE.py - classify image based on 3 parameters std, luminosity, hue.
  • image_classification_by_STD_SKU.py - classify image based on std (optimised for keeping images with the same SKU together)
  • image_classification_by_STD.py - classify image based on std

Usage

  1. Open the script and modify the following parameters in the main() function:
    • input_folder: Path to the directory containing your images
    • output_folder: Path where categorized images will be saved
    • recursive: Set to True for recursive directory scanning, False otherwise
    • DELETE_ORIGINALS : Set to True to move files or False to copy instead;
    • LUMINOSITY_INTERVAL, HUE_INTERVAL , STD_INTERVAL: Adjust these to change the granularity of categorization
  2. Run the script

Sample Output Example:

Let's assume we set the following parameters:

LUMINOSITY_INTERVAL = 25
STD_INTERVAL = 40
HUE_INTERVAL = 40

input_folder contains 1000 images

The script will create a directory structure in the specified output folder:

test-data/
├── Luminosity/
│   ├── 0-24/
│   ├── 25-49/
...
├── std/
│   ├── 0-39/
│   ├── 40-79/
│   ├── 80-119/
│   └── 120-159/
└── hue/
    ├── 0-39/
    ├── 40-79/
...

Each subdirectory would contain copies of the images that fall into that category.

image-contrast-analyser's People

Contributors

xryul avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.