Subscribe to DSC Newsletter

November 7, 2010
By Todos Logos
Here I present some functions I wrote to recreate some of the most common image effect available in all image editor.
They require the library rimage.
To load the image, use:

y <- read.jpeg("path")


To display the image, use:

plot(y)




Original image







Sepia tone


rgb2sepia <- function(img){
iRed <- img[,,1]*255
iGreen <- img[,,2]*255
iBlue <- img[,,3]*255

oRed <- iRed * .393 + iGreen * .769 + iBlue * .189
oGreen <- iRed * .349 + iGreen * .686 + iBlue * .168
oBlue <- iRed * .272 + iGreen * .534 + iBlue * .131

qw <- array( c(oRed/255 , oGreen/255 , oBlue/255), dim=c(dim(iRed)[1],dim(iRed)[2],3) )

imagematrix(qw, type="rgb")
}

plot(rgb2sepia(y))








Source: http://www.r-bloggers.com/r-is-a-cool-image-editor/

Views: 177

Follow Us

On Data Science Central

On DataViz

On Hadoop

© 2017   AnalyticBridge.com is a subsidiary and dedicated channel of Data Science Central LLC   Powered by

Badges  |  Report an Issue  |  Terms of Service