Welcome to imeffect

Image filter implementations written in Python (with scikit-image).

The algorithm of filters are ported from CamanJS.

Quick Start

from skimage.io import imread, imshow, show

import imeffect

img = imread('lena.png')

# applies the filter
f = filter.Lomo()
f(img)

# displays the filtered image
imshow(img)
show()

Demonstration

demonstration

API Reference

Filter Base

class imeffect.base.FilterBase

Abstract base class for filters.

__call__(img)

Applies filter effect to the given image (in place).

Derived class should override this method to implement the filter effect.

Warning

This method will modify the passed image directly.

class imeffect.base.BasicFilter

Abstract base class for basic filters.

The __call__() method will restrict all pixel values between 0 to 1.

_process(img)

Applies filter effect to the given image.

Derived class should override this method (instead of __call__()) to implement the filter effect.

class imeffect.base.LayeredFilter

Abstract base class for layered filters.

_LAYERS = ()

A list of filter layers.

Derived class should override this attribute.

See also

filter_as_layer, FilterLayer

Filter Layer

imeffect.layer.filter_as_layer(f)

Wraps the given filter as a pseudo-layer.

class imeffect.layer.FilterLayer(opacity, blender, filters)

Filter layer which can apply some filter effects to the given image, and then blended back into the parent layer.

Parameters:
  • opacity – opacity of this layer.
  • blender – blender function.
  • filters – a list of filters to be applied to the image.

See also

Blenders

__call__(parent, img)

Applies filter effects to the original image and blends it back to the parent layer.

Parameters:
  • parent – the parent layer.
  • img – the original image.

Blenders

imeffect.blender.normal(parent, layer)
imeffect.blender.multiply(parent, layer)
imeffect.blender.screen(parent, layer)
imeffect.blender.overlay(parent, layer)
imeffect.blender.difference(parent, layer)
imeffect.blender.addition(parent, layer)
imeffect.blender.exclusion(parent, layer)
imeffect.blender.softlight(parent, layer)
imeffect.blender.lighten(parent, layer)
imeffect.blender.darken(parent, layer)

Basic Filters

class imeffect.basic.FillColor(rgb)

Fills the image with a single RGB color.

Parameters:rgb – a (R, G, B) tuple. R, G, and B are integers range from 0 to 255.
class imeffect.basic.Brightness(adjust)

Changes the brightness of the image.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.Saturation(adjust)

Adjusts the color saturation of the image.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.Vibrance(adjust)

Increases the intensity of the more muted colors and leaves the already well-saturated colors alone.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.Greyscale

Computes luminance of an RGB image.

class imeffect.basic.Contrast(adjust)

Increases or decreases the contrast of the image.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.Hue(adjust)

Adjusts the hue of the image.

Parameters:adjust – float range from 0 to 100.
class imeffect.basic.Colorize(rgb, level)

Uniformly shifts the colors in an image towards the given color.

Parameters:
  • rgb – a (R, G, B) tuple. R, G, and B are integers range from 0 to 255.
  • level – float range from 0 to 100.
class imeffect.basic.Invert

Inverts color in the image.

class imeffect.basic.Sepia(adjust)

Applies sepia effect to the image.

Parameters:adjust – float range from 0 to 100.
class imeffect.basic.Gamma(adjust)

Adjusts gamma value of the image.

Parameters:adjust – float range from 0 to infinity.
class imeffect.basic.Noise(adjust)

Adds random noise to the image.

Parameters:adjust – float range from 0 to 100. The bigger the number the stronger the noise.
class imeffect.basic.Clip(adjust)

Clips color falls outside of the specified range.

Parameters:adjust – float range from 0 to 100.
class imeffect.basic.Channels(red=0, green=0, blue=0)

Modifies the intensity of any color channels individually.

Parameters:
  • red
  • green
  • blue – float range from 0 to 100.
class imeffect.basic.Curves(chans, cps)

Maps one color value to another by using the Bezier curve equation.

Parameters:
  • chans – a list of indices represents the channels to modify with the filter.
  • cps – a list of (X, Y) tuple represents the point coordinates. X and Y are integers range from 0 to 255.
class imeffect.basic.Exposure(adjust)

Adjusts the exposure of the image.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.Posterize(adjust)

Converts a continuous gradation of tone to several regions of fewer tones.

Parameters:adjust – float range from 0 to 100. The smaller the number the fewer the tones.
class imeffect.basic.Vignette(scale, strength=60)

Applies vignette effect to the image.

Parameters:
  • scale – float range from 0 to 100.
  • strength – float range from 0 to 100.
class imeffect.basic.Sharpen(adjust)

Emphasizes the edges in the image.

Parameters:adjust – float range from -100 to 100.
class imeffect.basic.GaussianBlur(radius)

Applies Gaussian blur to the image.

Parameters:radius – float range from 0 to infinity.

Pre-defined Filters

class imeffect.preset.Vintage(vignette=True)
class imeffect.preset.Lomo(vignette=True)
class imeffect.preset.Clarity(grey=False)
class imeffect.preset.SinCity
class imeffect.preset.Sunrise
class imeffect.preset.CrossProcess
class imeffect.preset.OrangePeel
class imeffect.preset.Love
class imeffect.preset.Grungy
class imeffect.preset.Jarques
class imeffect.preset.Pinhole
class imeffect.preset.OldBoot
class imeffect.preset.GlowingSun(vignette=True)
class imeffect.preset.HazyDays
class imeffect.preset.HerMajesty
class imeffect.preset.Nostalgia
class imeffect.preset.Hemingway
class imeffect.preset.Concentrate

See also

Demonstration

Filter Pool

class imeffect.pool.FilterPool

Filter pool which can hold a collection of filters.

register(cls, *args, **kwargs)

Registers the filter with class type and its arguments.

Parameters:cls – the class of registered filter.
register_as_layer(cls, *args, **kwargs)

Registers the filter and returns a pseudo-layer for the filter.

See also

FilterPool.register, filter_as_layer

Fork me on GitHub

Table Of Contents

Related Topics

This Page