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.
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.
Installing InstaRF is easy with only the following two steps:
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 imageExample:
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|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.