dither: Produce an image with ordered dithering

Description Usage Arguments

View source: R/dither.R

Description

An implementation of ordered or error diffusion dithering

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dither(
  img,
  res = 200,
  scale = NULL,
  target_palette = "c216",
  r = 1/8,
  bayer_size = 3,
  dither = "ordered",
  original = FALSE
)

Arguments

img

path or URL to image

res

horizontal resolution of output image in pixels (default = 200) This is only used if scale = NULL (which is the default behavior). The reason for this is to try and prevent very large images being processed by accident (large images will be slow to dither)

scale

scaling percentage (default = NULL). If scale is not NULL, it overrides the value of res. Full size = 100, half size = 50 etc.

target_palette

A target palette of colours for the output image. One of

  • "c216" - 216 colours spaced uniformly in RGB (default)

  • "c64" - 64 colours spaced uniformly in RGB

  • A vector of colours generated by the user

r

spread in color space for target palette (default = 1/8). This default is set to look 'OK' by eye. It is probably the factor that will most significantly change the appearance of the dithering. Higher numbers will give 'broader' more dithering and lower numbers will give 'tighter' less dithering

bayer_size

bayer matrix size (square matrix of side length 2^bayer_size) (default = 3)

dither

dither type, one of

  • "ordered" - Ordered dithering using a bayer matrix (default)

  • "diffusion" - Floyd/Steinberg error diffusion dithering from magick::image_map()

  • "none" - No dithering

original

return the original image (resized to res)


cj-holmes/ditherer documentation built on Feb. 25, 2021, 2:59 p.m.