library(OpenImageR)
library(rimager)

Overview

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.

Functions

circropper(input_path, margin)

Description:

Create a new image cropped by a circle mask and leave a margin

Arguments:

input_path: character the image file path
margin: double the distance between circle boundary and the original image boundary

redusize(input_file, output_file, width, height)

Description:

A new image with the modified width and height will be created

Arguments:

input_file: character, the file path for the input file
output_file: character, the file path for the output file
width: integer, the width of the reduced image
height: integer, the height of the reduce image

imgfilter(input_path, filter_type, strength, output_path = NULL)

Description:

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.

Arguments:

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

reducolor(style, input_path, output_path = NULL)

Description:

Reduce the image color to either 2 or 8 colors for cartoonized effect.

Arguments:

style: integer, either 0 or 1 0 for white and black colors, 1 for 8 colors
input_path: character, the image file path
output_path: character, if not Null, the modified image will be saved in the provided folder path and name

Examples

We will use mandrill.jpg saved in the images folder of this repository.

circropper

circropper("../images/mandrill.jpg", 0)

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)