README.md

rimgtool

R build
status

codecov

project vignette

The goal of rimgtool is to perform image processing in R.

Team Members

| Name | Github | | ---------- | ----------------------------------------------- | | Ruidan Ni | rita-ni | | Frank Lu | Frank Lu | | Kexin Zhao | Margaret8521 |

Package Overview

rimgtool is a R package that is intended to allow users to compress, sharpen and crop an input image. Our package only allows the input image to be a 3D vector and output the manipulated image as a 3D numpy array. It contains three functions: compress(), sharpen(), and crop().

Feature Description

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("UBC-MDS/rimgtool")

Related Packages

There are a few existing R packages that perform image manipulation such as magick and imager, which could be used for simplifying high-quantity images. However, these packages are usually very comprehensive and provide many functions to process the image in different ways. There are very few smaller packages available on Github to perform simpler image processing tasks like image croping such as this package using seam carving mechanism. Our implementation of image processing is a less sophisticated version of the existing image processing tools, we focus specifically on image compression, croping, and sharpening using simpler and easy to understand algorithms.

Dependencies

Usage

| Task | After import rimgtool | | ----------------------------------------------------- | ------------------------------ | | Compress an image to include 2^4 = 16 colors | rimgtool.compress(image, 4L) | | Sharpen an image by detecting and enhancing the edges | rimgtool.sharpen(image) | | crop an image to desired width and height | rimgtool.crop(image, 20, 20) |

Usage scenario

First, we should load the rimgtool library:

library(rimgtool)

We are going to use butterfly.jpg image which is in the img folder of this repository for illustration.

We can apply the compress function: compress(image, 4L)

library(jpeg) # install.packages('jpeg')
library(OpenImageR) # install.packages('OpenImageR')
img <- jpeg::readJPEG("img/butterfly.jpg")
jpeg::writeJPEG(compress(img, 4L), target = 'img/compress.jpeg')

We can also apply the crop function:

crop(img, 400, 400)

jpeg::writeJPEG(crop(img, 400, 400), target = 'img/crop.jpeg')

We can also apply the sharpen function: sharpen(image)

# install.packages('jpeg')
library(jpeg)
img <- jpeg::readJPEG("img/free-wallpaper.jpg")
jpeg::writeJPEG(sharpen(img), target = 'img/sharpened.jpeg')

The documentation is hosted on pkgdown, and you can also refer to our project vignette.



UBC-MDS/Rgroup12 documentation built on April 1, 2020, 4:36 a.m.