This package provides three functions: - sharpen - compress - crop
As the name suggests, we aim to providing some tools for easy image processing. To use this package, follow the installation guide on README and install this package. Then, import the package.
Name | Github |
---|---|
Ruidan Ni | rita-ni |
Frank Lu | Frank Lu |
Kexin Zhao | Margaret8521 |
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 numpy array and output the manipulated image as a 3D numpy array. It contains three functions: compress()
, sharpen()
, and crop()
.
compress
:
sharpen
:
crop
:
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("UBC-MDS/rimgtool")
#> Downloading GitHub repo UBC-MDS/rimgtool@master
#>
checking for file ‘/tmp/RtmpI2yYIv/remotes5ee65f5e5eb5/UBC-MDS-rimgtool-c70d854/DESCRIPTION’ ...
✓ checking for file ‘/tmp/RtmpI2yYIv/remotes5ee65f5e5eb5/UBC-MDS-rimgtool-c70d854/DESCRIPTION’
#>
─ preparing ‘rimgtool’:
#> checking DESCRIPTION meta-information ...
✓ checking DESCRIPTION meta-information
#>
─ checking for LF line-endings in source and make files and shell scripts
#>
─ checking for empty or unneeded directories
#>
─ building ‘rimgtool_0.0.0.9000.tar.gz’
#>
#>
#> Installing package into '/tmp/RtmpZF4Lpy/temp_libpath5087cace86a'
#> (as 'lib' is unspecified)
Then, import this package in R console:
library(rimgtool)
Shrpen
functionThe purpose of this function is to detect and enhance the edges in a grey-scale image using a 2-D convolution so that the details can stand out. Displayed BELOW, the photo on the left-hand side is before sharpening, and the photo on the right-hand side is after sharpening. As the details are enhanced by our sharpening function, the center portion of the flower look more focused.
Apply sharpen
function: sharpen(img)
# install.packages('jpeg')
library(jpeg)
img <- jpeg::readJPEG("img/free-wallpaper.jpg")
jpeg::writeJPEG(sharpen(img), target = 'img/sharpened.jpeg')
Compress
functionWe 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, 4)
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')
Crop
functionWe can also apply the crop function:
jpeg::writeJPEG(crop(img, 400, 400), target = 'img/crop.jpeg')