This document introduces Rgram and shows how to use the package.

Introduction to Rgram

Images form a significant part of the data in today’s world. Whether you want to enhance your poorly-lit profile picture or analyze satellite images, filters are your best friends.Rgram aims to help you to create four filters for your image:

  • flipping: This function can be used to flip the image horizontally in black and white.

  • greyscale: This function can be used to convert a color image into a greyscale image.

  • padding: This function can be used to add padding to the the borders of an image.

  • rotate: This function can be used to rotate an image by the specified number of degrees.

Data: An image to be called using ‘library(imager)’ or ‘library(png)’

To call/read your input image you need to load two libraries: imager and png.

library(imager)
#> Loading required package: magrittr
#> 
#> Attaching package: 'imager'
#> The following object is masked from 'package:magrittr':
#> 
#>     add
#> The following object is masked from 'package:Rgram':
#> 
#>     grayscale
#> The following objects are masked from 'package:stats':
#> 
#>     convolve, spectrum
#> The following object is masked from 'package:graphics':
#> 
#>     frame
#> The following object is masked from 'package:base':
#> 
#>     save.image
library(png)

Examples

‘greyscale’ function

grayscale("https://raw.githubusercontent.com/UBC-MDS/Rgram/master/tests/testthat/test_images/grayscale/sample.jpg") %>% plot()

‘rotate’ function

rotate("https://raw.githubusercontent.com/UBC-MDS/Rgram/master/tests/testthat/test_images/rotate/sample.jpg", 60) %>% 
  plot()

‘padding’ function

padding("https://raw.githubusercontent.com/UBC-MDS/Rgram/master/tests/testthat/test_images/padding/sample.jpg", 20) %>% 
  plot()