Betty Zhou
Linyang Yu
Reza Bagheri
Simon Chiu
Image processing uses computer algorithms to enhance an image or to extract useful information from it. In this package, we have implemented some R functions for image processing. These functions perform Gaussian blurring, Laplacian edge detection, and color changing.
- Gaussian Blur
This function performs convolution to de-emphasize differences in adjacent pixel values with a Gaussian distribution. The blurring effect removes detail and noise in the input image. - Laplacian Edge Detecting
This function performs convolution to emphasize differences in adjacent pixel values. The function detects edges by sharpening/highlighting the edges of an image. - RBG Manipulation
This function adjusts the red, blue and green intensity of an image by applying different weights for each RBG channel. This is similar to a colour filter in Instagram.
It is important to note that are several packages that have similar image processing functionality. For example, InstaR is a R package that contains the three functions: blur, flip and greyscale to transform images. Or a similar package called magick exists which has some image processing filters like blur, crop and trim. In this project, we plan to implement three more image processing functions in R by exploring additional filters.
- R: R folder contains all of our functions:
- gaussian_blur.R
- laplacian_filter.R
- RGB_manipulation.R
- Testing Units Design: test_r
- Contains images for testing: test_image
- Testing units for Gaussian Blurring: test_gaussian_blur.R
- Testing units for Laplacian edge: test_Laplacian_edge_detecting.R
- Testing units for RGB channel: test_RGB_manipulation.R
- CONTRIBUTING.md
- Code_of_CONDUCT.md
- LICENSE
- README.md
Installing InstaRF is easy with only the following two steps:
- Open your R studio
- Enter
devtools::install_github("UBC-MDS/InstaRF", build_opts = c("--no-resave-data", "--no-manual"))
to console.
To build vignettes:
devtools::install_github("UBC-MDS/InstaRF", build_opts = c("--no-resave-data", "--no-manual"))
browseVignettes(package ='InstaRF')
library(InstaRF)
gaussian_blur(input_image_path, output_image_path, sigma = 1)
Arguments:
input_image_path
: Path to the input imageoutput_image_path
: Path to the output imagefilter_shape
: Size of the filtersigma
: Standard diviation of the gaussian distribution (higher sigma size allows stronger blurring)
Example:
gaussian_blur("tests/testthat/test_img/carnovsky_RGB_1.png", "tests/testthat/test_img/test.png", sigma = 1)
Before:
After:
RGB_manipulation(input_path, output_path, R = 2, G = 2, B = 2)
Arguments:
input_path
: Path to the input imageoutput_path
: Path to the output imageR
: Adjusting intensity for red channel (integer)B
: Adjusting intensity for blue channel (integer)G
: Adjusting intensity for green channel (integer)
Example:
RGB_manipulation(""tests/testthat/test_img/carnovsky_RGB_1.png", "tests/testthat/test_img/Carnovsky_RGB_manipulated.png", R = 1, G = 1, B = 5)
Before:
After:
laplacian_edge_detecting(input_image, output_image)
Arguments:
input_path
: Path to the input imageoutput_path
: Path to the output image
Example:
laplacian_filter("tests/testthat/test_img/test_img_laplacian_bird_before.png", "tests/testthat/test_img/test_img_laplacian_bird_after.png")
Before:
After:
The package passed all the tests that were planned before.
It had 100% branch coverage:
The functions passed all the tests:
and R cmd test was also passed:
In the root of the repository, input devtool::test()
or devtool::check()
, the former will generate the test units reports and the later will give you a full report of the package.
Results for devtool::test()
testthat | png | spatialfil |