dithr
Error Diffusion Ditheing in RstatsA small R package for error diffusion dithering in R.
Comes with 10 pre-defined error diffusion matrices:
To Do
# install.packages('magick')
# source("https://bioconductor.org/biocLite.R")
# biocLite("EBImage")
devtools::install_bitbucket('coolbutuseless/dithr')
#-----------------------------------------------------------------------------
# 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)
dithered_matrix <- dithr::dither(m, dithr::diffusion_matrix$floyd_steinberg)
dithr::plot_matrix(dithered_matrix)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.