Skip to content

Latest commit

 

History

History
357 lines (234 loc) · 11.7 KB

filters.md

File metadata and controls

357 lines (234 loc) · 11.7 KB

Image Processing

The Dart Image Library provides a number of functions for applying color filters to images. These functions will be applied to the image itself rather than create a new image.

Masking Filter Functions

Most of the drawing and filter functions can take a mask parameter. A mask is an image that controls the blending of the filter per pixel. You can specify which channel of the mask, or its luminance, to use for the blending value. Where the mask channel is full intensity, the filter has full effect, and where the mask channel is 0, it has no effect; and values in between will blend the filter with the original image.

Using a mask image to blend the sketch filter:

mask sketchMask

Filter Functions

Image adjustColor(Image src,
{ Color? blacks, Color? whites, Color? mids, num? contrast, num? saturation, num? brightness, num? gamma, num? exposure,
num? hue, num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

adjustColor

Image billboard(Image src, { num grid = 10, num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

billboard

Image bleachBypass(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

bleachBypass

Image bulgeDistortion(Image src, { int? centerX, int? centerY, num? radius, num scale = 0.5,
    Interpolation interpolation = Interpolation.nearest, Image? mask, Channel maskChannel = Channel.luminance })

bulgeDistortion

Image bumpToNormal(Image src, { num strength = 2 })

bumpToNormal

Image chromaticAberration(Image src, { int shift = 5, Image? mask, Channel maskChannel = Channel.luminance })

chromaticAberration

Image colorHalftone(Image src, { num amount = 1, int? centerX, int? centerY,
    num angle = 180, num size = 5, Image? mask, Channel maskChannel = Channel.luminance })

colorHalftone

Image colorOffset(Image src, { num red = 0, num green = 0, num blue = 0, num alpha = 0,
    Image? mask, Channel maskChannel = Channel.luminance })

colorOffset

Image contrast(Image src, { required num contrast, Image? mask, Channel maskChannel = Channel.luminance,
    ContrastMode mode = ContrastMode.proportional})

contrast

Image convolution(Image src, { required List<num> filter,
    num div = 1.0, num offset = 0.0, num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

convolution

Image copyImageChannels(Image src, { required Image from, bool scaled = false,
    Channel? red, Channel? green, Channel? blue, Channel? alpha,
    Image? mask, Channel maskChannel = Channel.luminance })

copyImageChannels

Image ditherImage(Image image, { Quantizer? quantizer,
  DitherKernel kernel = DitherKernel.floydSteinberg,
  bool serpentine = false })

ditherImage

Image dotScreen(Image src, { num angle = 180, num size = 5.75, int? centerX,
    int? centerY, num amount = 1, Image? mask,
    Channel maskChannel = Channel.luminance })

dotScreen

Image dropShadow(Image src, int hShadow, int vShadow, int blur, { Color? shadowColor })

dropShadow

Image edgeGlow(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

edgeGlow

Image emboss(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

emboss

Image gamma(Image src, { required num gamma, Image? mask, Channel maskChannel = Channel.luminance })

gamma

Image gaussianBlur(Image src, { required int radius, Image? mask, Channel maskChannel = Channel.luminance })

gaussianBlur

Image grayscale(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

grayscale

Image hdrToLdr(Image hdr, { num? exposure })

hdrToLdr

Image hexagonPixelate(Image src, { int? centerX, int? centerY, int size = 5,
    num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

hexagonPixelate

Image invert(Image src, { Image? mask, Channel maskChannel = Channel.luminance })

invert

Image luminanceThreshold(Image src, { num threshold = 0.5,
    bool outputColor = false, num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

luminanceThreshold

Image monochrome(Image src, { Color? color, num amount = 1,
    Image? mask, Channel maskChannel = Channel.luminance })

monochrome

Image noise(Image image, num sigma, { NoiseType type = NoiseType.gaussian, Random? random,
    Image? mask, Channel maskChannel = Channel.luminance })

noise

Image normalize(Image src, { required num min, required num max,
    Image? mask, Channel maskChannel = Channel.luminance })

normalize

Image pixelate(Image src, { required int size,
    PixelateMode mode = PixelateMode.upperLeft, num amount = 1, Image? mask,
    Channel maskChannel = Channel.luminance })

pixelate

Image quantize(Image src, { int numberOfColors = 256, QuantizeMethod method = QuantizeMethod.neuralNet,
  DitherKernel dither = DitherKernel.none, bool ditherSerpentine = false })

quantize

Image reinhardTonemap(Image hdr, { Image? mask, Channel maskChannel = Channel.luminance })

reinhardTonemap

Image remapColors(Image src, { Channel red = Channel.red, Channel green = Channel.green,
  Channel blue = Channel.blue, Channel alpha = Channel.alpha })

remapColors

Image scaleRgba(Image src, { required Color scale, Image? mask, Channel maskChannel = Channel.luminance })

scaleRgba

Image separableConvolution(Image src, { required SeparableKernel kernel,
    Image? mask, Channel maskChannel = Channel.luminance })

separableConvolution

Image sepia(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

sepia

Image sketch(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

sketch

Image smooth(Image src, { required num weight, Image? mask, Channel maskChannel = Channel.luminance })

smooth

Image sobel(Image src, { num amount = 1, Image? mask, Channel maskChannel = Channel.luminance })

sobel

enum SolarizeMode { highlights, shadows }
Image solarize(Image src, { required int threshold, SolarizeMode mode = SolarizeMode.highlights })

solarize

Image stretchDistortion(Image src, { int? centerX, int? centerY,
    Interpolation interpolation = Interpolation.nearest, Image? mask, Channel maskChannel = Channel.luminance })

stretchDistortion

Image vignette(Image src, { num start = 0.3, num end = 0.85,
    num amount = 0.9, Color? color, Image? mask, Channel maskChannel = Channel.luminance })

vignette