Coder Social home page Coder Social logo

imagetools's Introduction

ImageTools

Collection of console tools for image processing. The ImageTools repository contains scripts for perfoming:

  • Individual image processing located under ImageTools
  • Batch processing: the scripts perform a transformation of all the images inside a folder and subfolders. The result are placed inside a new folder with the same name as the source directoru plus '_out'. The scripts are located on ImageTools/Batch.
  • Datasets: Tools for Machine Learning image datasets processing.

Run the scripts following the next pattern:

python -m ImageTools.Batch.script_name -A --args /image/path.png

Batch Tools

Scripts for performing image processing of all the images located under a folder and sub-folders.

Create PNG (Alpha-mated images)

Generate a transparency image and save as PNG. Automatic background subtraction from plain colors. Four backround colors: White, black, green and auto. Im auto mode: the foreground detection is based on the most common color of the image. Example auto mode transparency generator:

alt text

Usage

python -m ImageTools.Batch.create_png  [-s] [-c COLOR] [-x] path

Positional arguments:

path:     Image path or directory containing images

Optional arguments:

-s, --show           Show changes on image for visual debugging

-c COLOR, --color     Background color of the image, available: white, black, green or auto

-x, --convex_hull        Get alpha channel with convex hull

Cropper

Batch crop part of all the images located in a folder and subfolders. There are available 4 ways to crop the images:

  • Square centered: crop a square centered of the image with a specified size
  • Y-axis range: crop a range of the image in the y-axis
  • X-axis range: crop a range of the image in the x-axis
  • Automatic: crop arrount the largest blob in the alpha channel

Image cropper examples:

alt text

Usage:

python -m ImageTools.Batch.cropper [-s SIZE] [-y YRANGE] [-x XRANGE] [-q QUALITY] [-a] path

Positional arguments:

path :     Source directory

Optional arguments:

-s SIZE, --size               Size of the side cropped area centered on the image

-y YRANGE, --yrange    Range of image in y axis (y_init, y_final)

-x XRANGE, --xrange    Range of image in x axis (x_init, x_final)

-q QUALITY, --quality   Output file image quality

-a, --auto                        Crop automatic based alpha channel

Resize

Scale all the images inside folder and subfolders. This script creates a new folder in the same location with the same name plus '_resized'.

Usage:

python -m ImageTools.Batch.resize [-h] [-s SCALE] [-q QUALITY] path

Positional arguments:

path                                       Image path or directory containing images

Optional arguments:

-s SCALE, --scale               Scale both widht and height

-q QUALITY, --quality        Output file image quality

PNG from images

Generate a transparency image by removing the background using two images (Background and Foreground) and save as PNG.

alt text

Usage:

python -m ImageTools.png_from_ims [-h] [-t THRESHOLD] [-m MIN] [-s] [-c] [-b] [-u] im0 im1

Positional arguments:

im0                                   Path to background image

im1                                   Path to foreground image

Optional arguments:

-t THRESHOLD, --threshold             Percentage of pixels that changed to be considered a change

-m MIN, --min                                     Minimum pixel chamge to be considered

-s, --show                                           Show changes on image for visual debugging

-c, --crop                                            Crop image around largest contour

-b, --background                               Keep image background

-u, --hull                                             Use convex hull for mask generation

When used for batch processing the images inside the folders the name most be ended in '_0' in background and '_1' and the same arguments are available.

Blur

Add gaussian blur to all images located in folder and subfolders. Creates an output folder located in the same root location with the same as the source.

Usage:

python -m ImageTools.Batch.blur [-h] [-k KERNELSIZE] path

Positional arguments:

path Image path or directory containing images

Optional arguments:

-k KERNELSIZE, --kernelSize            Blur filter kernel size (k,k)

Crop image change

Creates a new image by cropping the area of foreground that changes between foreground and background.

alt text

Usage:

 python -m ImageTools.Batch.crop_change [-h] [-t THRESHOLD] [-m MIN] [-s] [-u] im0 im1

Positional arguments:

im0                                                      Path to background image

im1                                                      Path to foreground image

Optional arguments:

-t THRESHOLD, --threshold             Percentage of pixels that changed to be considered a change

-m MIN, --min                                     Minimum pixel chamge to be considered

-s, --show                                            Show changes on image for visual debugging

-u, --hull                                               Use convex hull for mask generation

Dataset Tools

Tools for Machine Learning image datasets processing.

Png from COCO

Generate transparency image using COCO segmentation labels

Image Analyzers

Scripts for performing color and shape image analysis

Histogram

Calculates and display image color histogram

alt text

Usage:

 python -m ShowHistogram [-h] im_path

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.