Collection of basic image processing algorithms for processing
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Adds missing files for #22 Sep 22, 2018
img Adds missing files for #22 Sep 22, 2018
library Fixes #23, Closes #22 Sep 22, 2018
reference Adds missing files for #22 Sep 22, 2018
src/milchreis/imageprocessing Adds missing files for #22 Sep 22, 2018
.gitattributes Update .gitattributes Jan 5, 2018
LICENSE Initial commit Jan 4, 2018 Update Sep 22, 2018 Solves #20 May 9, 2018

Image processing for Processing

This library collects various image processing algorithms and provides a simple access to them. All algorithms are implemented in Java and runs without any other dependencies. If you need high power performance better use opencv for processing.


If you want to use this library in your processing sketch you can download it via the intergrated Contribution Manager. alt install


Original image

alt original

Photo is taken by me more here


Grayscale image

alt grayscale

PImage processedImage = Grayscale.apply(image);

Flip image

alt flip

PImage processedImage = Flip.apply(image, horizontal, vertical);  // horizontal and vertical are boolean

Invert colors

alt invert colors

// invertRed, invertGreen and invertBlue are boolean
PImage processedImage = InvertColors.apply(image, invertRed, invertGreen, invertBlue);  

Threshold image

alt threshold

PImage processedImage = Threshold.apply(image);  // Auto threshold
PImage processedImage = Threshold.apply(image, value);  // Threshold value between 0 and 255

Dilation image

alt dilation

PImage processedImage = Dilation.apply(image, radius);  // radius is a positive number

Erosion image

alt erosion

PImage processedImage = Erosion.apply(image, radius);  // radius is a positive number

Vignette image

alt vignette

// intensity and vignetteWidth are floats between 0.0 and 1.0
PImage processedImage = Vignette.apply(image, intensity, vignetteWidth); 


alt grayscale

PImage processedImage = Quantization.apply(image, shades);  // shades is a positive number between 1 and 255


Gaussian blur image

alt gaussian

PImage processedImage = Gaussian.apply(image, 7, 0.84089642);   // kernel size and sigma 

Pixelize image

alt pixelation

// pixelsize is a positive number
PImage processedImage = Pixelation.apply(image, pixelsize); 
// Pixelize a sub area of the input image
PImage processedImage = Pixelation.apply(image, pixelsize, subX, subY, subWidth, subHeight);  


alt tilt-shift

PImage processedImage = TiltShift.apply(image, blurIntensity, horizontal, position, sharpWideness);   

Edge detection

Canny's algorithm

alt canny-edge

PImage processedImage = CannyEdgeDetector.apply(image);

Sobels algorithm

alt sobel-edge

PImage processedImage = SobelEdgeDetector.apply(image);
// for colored sobel (for each color channel)
PImage processedImage = SobelEdgeDetector.apply(image, false);



alt autobalance

PImage processedImage = Brightness.apply(image, value); 
// value isa positive number for brighting up or a negative for darken down

Changing highlights

alt vignette

// intensity between -1.0 and 1.0
PImage processedImage = Lights.apply(image, intensity); 

Changing shadows

alt vignette

// intensity between -1.0 and 1.0
PImage processedImage = Shadows.apply(image, intensity); 

AutoBalance image

alt autobalance

PImage processedImage = AutoBalance.apply(image);

Bloom image

alt bloom

PImage processedImage = Bloom.apply(image, intensity);  // intensity between 0 and 255

Sharpen image

alt sharpen

PImage processedImage = Sharpen.apply(image, sharpIntensity);  // sharpIntensity between 0.0 and 10.0

Color shift image

alt sharpen

// hue is a value between 0 and 360
// offset is the color range which is accepted (in hue range)
// shift is the number of the subtracted or added hue value
PImage processedImage = ColorShift.applyHue(image, hue, offset, shift);  // or short: ColorShift.apply(image, hue, offset, shift)
PImage processedImage = ColorShift.applySaturation(image, hue, offset, shift);
PImage processedImage = ColorShift.applyBrightness(image, hue, offset, shift);


Lookup table image

alt lookup-table

PImage processedImage = LUT.apply(image, style); 

Glitch image

alt lookup-table

PImage processedImage = Glitch.apply(image, intensity, scanlineheight);


alt dithering

// default dithering algorithm is BAYER_4x4
PImage processedImage = Dithering.apply(image);
// change algrithm: BAYER_2x2, BAYER_4x4, BAYER_8x8
PImage processedImage = Dithering.apply(image, Dithering.Algorithm.BAYER_8x8);
// use a curstom kernel (kernel = float[])
PImage processedImage = Dithering.aapply(PImage image, kernel);  

Halftone image

alt halftone

PImage processedImage = Halftone.apply(image, dotsize);  // dot size in pixel
PImage processedImage = Halftone.apply(image, dotsize, grid); // grid = true, on false honeycomb style
PImage processedImage = Halftone.apply(image, dotsize, foreground, background);  // background and foreground colors
PImage processedImage = Halftone.apply(image, dotsize, foreground, background, grid);
PImage processedImage = Halftone.apply(image, dotsize, foreground, background, spacing, grid); // size between dots in pixels

ASCII image

alt ascii

PImage processedImage = ASCII.apply(image);
// characterset = ASCII.SHORT_SET or ASCII.LONG_SET, another String from black to white
PImage processedImage = ASCII.apply(image, characterset); 
PImage processedImage = ASCII.apply(image, characterset, fontSize); // fontSize is an integer
PImage processedImage = ASCII.apply(image, characterset, fontSize, foregroundColor, backgroundColor, toneInColor);


Stacked images

alt stacked

// Add so many images in the end as you need
PImage processedImage = Stacker.apply(Stacker.ALGORITHM.AVERAGE, image1, image2);
PImage processedImage = Stacker.apply(Stacker.ALGORITHM.MEDIAN, image1, image2);

Blending two images

alt blending

// intensity is a float between 0.0 and 1.0
PImage processedImage = Blend.apply(image1, image2, intensity);

Special thanks

My special thanks goes to avatarr for implementing and publishing basic algorithms. Also thank you very much Tom Gibara for your great blog post and the implementation of the canny edge detector.