README.md

dithr Error Diffusion Ditheing in Rstats

A small R package for error diffusion dithering in R.

Comes with 10 pre-defined error diffusion matrices:

To Do

Installation

# install.packages('magick')
# source("https://bioconductor.org/biocLite.R")
# biocLite("EBImage")
devtools::install_bitbucket('coolbutuseless/dithr')

Example

#-----------------------------------------------------------------------------
# Using imagemagick to load and convert the image to grayscale
#-----------------------------------------------------------------------------
im <- magick::image_read("./figure/Portal_Companion_Cube.jpg") %>%
  magick::image_convert(type = 'grayscale') %>% 
  magick::image_scale(geometry="50%")


#-----------------------------------------------------------------------------
# Extract the matrix of values
#-----------------------------------------------------------------------------
m <- magick::as_EBImage(im)@.Data

#-----------------------------------------------------------------------------
# Show the original image
#-----------------------------------------------------------------------------
dithr::plot_matrix(m)

plot of chunk unnamed-chunk-2

dithered_matrix <- dithr::dither(m, dithr::diffusion_matrix$floyd_steinberg)
dithr::plot_matrix(dithered_matrix)

plot of chunk unnamed-chunk-3



coolbutuseless/dithr documentation built on May 14, 2019, 6:09 a.m.