rimager
is a R package that provides a quick and easy way to perform image processing and graphic editing. The package includes four functionalities: reduce the size of the image, crop the image into a circle, reduce the image colors, and blur or sharpen the image.
imgfilter(input_path, filter_type, strength, output_path = NULL)
The filter types include ‘blur’ and ‘sharpen’; where blur blends neighboring pixels and sharpen enhances edges. The strength of the filter indicates how much of effect is applied to the image; where 0 is no effect and 1 is very strong effect.
input_path
: character the file path of the image filter_type
: character filter to be applied to the input image. options: ‘blur’ and ‘sharpen’ strength
: numeric or integer (0 to 1) the strength of the selected filter effect output_path
: character or NULL (default NULL); the file path of the resultant image
We will use mandrill.jpg
saved in the images
folder of this repository.
redusize
mandrill_redusize <- redusize("../images/mandrill.jpg", "../images/mandrill_redusize.jpg", 297, 200)
imageShow(mandrill_redusize)
imgfilter
mandrill_imgfilter <- imgfilter("../images/mandrill.jpg", "blur", 0.4)
imageShow(mandrill_imgfilter)
reducolor
#style 0, reduce the image color to white and black and save the new image mandrill_reducolor0.jpg in
#the images folder
mandrill_reducolor0 <- reducolor(0, "../images/mandrill.jpg", "../images/mandrill_reducolor0.jpg")
imageShow(mandrill_reducolor0)
#style 1, reduce the image color to 8 colors. And because the output_path is NULL, the image will
#not be saved as a file.
mandrill_reducolor1 <- reducolor(1, input_path = "../images/mandrill.jpg", output_path = NULL)
imageShow(mandrill_reducolor1)