This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the 2-dimensional convolution function | |
FloydConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 1:(dim(a)[1]-1)){ | |
for(j in 1:(dim(a)[2]-1)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P | |
a[i,j] <- P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Floyd-Steinberg dithering | |
# the 2-dimensional convolution function | |
FloydConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 1:(dim(a)[1]-1)){ | |
for(j in 1:(dim(a)[2]-1)){ | |
P <- trunc(a[i,j]+0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Floyd-Steinberg dithering | |
# the 2-dimensional convolution function | |
FloydConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 1:(dim(a)[1]-1)){ | |
for(j in 1:(dim(a)[2]-1)){ | |
P <- trunc(a[i,j]+0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bill Atkinson dithering | |
AtkinConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Jarvis-Judice-Ninke dithering | |
JJNConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sierra 2-4a dithering filter | |
Sierra24aConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stucki dithering | |
StuckiConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Burkes dithering | |
BurkesConvolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sierra2 dithering | |
Sierra2Convolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sierra3 dithering | |
Sierra3Convolution <- function(a){ | |
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2]) | |
for(i in 2:(dim(a)[1]-2)){ | |
for(j in 2:(dim(a)[2]-2)){ | |
P <- trunc(a[i,j]+0.5) | |
e <- a[i,j] - P |
OlderNewer