Learn R Programming

OpenImageR

The OpenImageR package is an image processing library. It includes functions for image preprocessing, filtering and image recognition. More details on the functionality of OpenImageR can be found in the first, second and third blog-posts, and in the package Documentation ( scroll down for information on how to use the docker image )

UPDATE 06-11-2018

As of version 1.1.2 the OpenImageR package allows R package maintainers to perform linking between packages at a C++ code (Rcpp) level. This means that the Rcpp functions of the OpenImageR package can be called in the C++ files of another package. In the next lines I'll give detailed explanations on how this can be done:

Assumming that an R package ('PackageA') calls one of the OpenImageR Rcpp functions. Then the maintainer of 'PackageA' has to :

  • 1st. install the OpenImageR package to take advantage of the new functionality either from CRAN using,

install.packages("OpenImageR")
 

or download the latest version from Github using the remotes package,


remotes::install_github('mlampros/OpenImageR')
 
  • 2nd. update the DESCRIPTION file of 'PackageA' and especially the LinkingTo field by adding the OpenImageR package (besides any other packages),

LinkingTo: OpenImageR
  • 3rd. open a new C++ file (for instance in Rstudio) and at the top of the file add the following 'headers', 'depends' and 'plugins',

# include <RcppArmadillo.h>
# include <OpenImageRheader.h>
// [[Rcpp::depends("RcppArmadillo")]]
// [[Rcpp::depends(OpenImageR)]]

The available C++ classes (Utility_functions, Gabor_Features, Gabor_Features_Rcpp, HoG_features, Image_Hashing) can be found in the inst/include/OpenImageRheader.h file.

A complete minimal example would be :


# include <RcppArmadillo.h>
# include <OpenImageRheader.h>
// [[Rcpp::depends("RcppArmadillo")]]
// [[Rcpp::depends(OpenImageR)]]


// [[Rcpp::export]]
arma::mat rgb_2gray_exp(arma::cube RGB_image) {

  oimageR::Utility_functions UTLF;
  return UTLF.rgb_2gray_rcpp(RGB_image);
}

Then, by opening an R file a user can call the rgb_2gray_exp function using,


Rcpp::sourceCpp('example.cpp')              # assuming that the previous Rcpp code is included in 'example.cpp' 
             
set.seed(1)
im_rgb = array(runif(30000), c(100, 100, 3))

im_grey = rgb_2gray_exp(im_rgb)

str(im_grey)

Use the following link to report bugs/issues,

https://github.com/mlampros/OpenImageR/issues

UPDATE 29-11-2019

Docker images of the OpenImageR package are available to download from my dockerhub account. The images come with Rstudio and the R-development version (latest) installed. The whole process was tested on Ubuntu 18.04. To pull & run the image do the following,


docker pull mlampros/openimager:rstudiodev

docker run -d --name rstudio_dev -e USER=rstudio -e PASSWORD=give_here_your_password --rm -p 8787:8787 mlampros/openimager:rstudiodev

The user can also bind a home directory / folder to the image to use its files by specifying the -v command,


docker run -d --name rstudio_dev -e USER=rstudio -e PASSWORD=give_here_your_password --rm -p 8787:8787 -v /home/YOUR_DIR:/home/rstudio/YOUR_DIR mlampros/openimager:rstudiodev

In the latter case you might have first give permission privileges for write access to YOUR_DIR directory (not necessarily) using,


chmod -R 777 /home/YOUR_DIR

The USER defaults to rstudio but you have to give your PASSWORD of preference (see https://rocker-project.org/ for more information).

Open your web-browser and depending where the docker image was build / run give,

1st. Option on your personal computer,

http://0.0.0.0:8787 

2nd. Option on a cloud instance,

http://Public DNS:8787

to access the Rstudio console in order to give your username and password.

Citation:

If you use the code of this repository in your paper or research please cite both OpenImageR and the original articles / software https://CRAN.R-project.org/package=OpenImageR:

@Manual{,
  title = {{OpenImageR}: An Image Processing Toolkit},
  author = {Lampros Mouselimis},
  year = {2023},
  note = {R package version 1.3.0},
  url = {https://CRAN.R-project.org/package=OpenImageR},
}

Copy Link

Version

Install

install.packages('OpenImageR')

Monthly Downloads

2,328

Version

1.3.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Last Published

July 8th, 2023

Functions in OpenImageR (1.3.0)

HOG

calculate the HOG (Histogram of oriented gradients) for an image
HOG_apply

calculate the HOG (Histogram of oriented gradients) for a matrix, array or a folder of images
edge_detection

edge detection (Frei_chen, LoG, Prewitt, Roberts_cross, Scharr, Sobel)
List_2_Array

convert a list of matrices to an array of matrices
MinMaxObject

minimum and maximum values of vector, matrix, data frame or array
flipImage

flip image horizontally or vertically
RGB_to_Lab

Conversion of RGB to Lab colour type
gamma_correction

Gamma correction
delationErosion

Delation or Erosion of an image
gaussian_kernel

gaussian-kernel
rgb_2gray

convert an RGB image to Gray
rotateFixed

Rotate an image by 90, 180, 270 degrees
NormalizeObject

normalize a vector, matrix or array (in the range between 0 and 1)
sec_gaus_bl

secondary function for downsampling
sec_resiz_array

secondary function for 'resizeImage' [ array ]
ZCAwhiten

zca whiten of an image
RGB_to_HSV

Conversion of RGB to HSV colour type
average_hash

calculation of the 'average hash' of an image
writeImage

This function writes 2- or 3-dimensional image (where the third dimension is equal to 3) data to a file
dhash

calculation of the 'dhash' of an image
convolution

convolution
func_chech_range

function to check the range of values of an image or normalize an image
func_transform

secondary function for HOG_apply
cropImage

crop an image
crop_image_secondary

crop an image in R [ for RGB or grey images ]
readImage

this function reads various types of images
load_binary

loads either 2- or 3-dimensional data (where the third dimension is equal to 3) from a binary file
resizeImage

resize an image using the 'nearest neighbors' or the 'bilinear' method
superpixel_bbox

Bounding box for the superpixel labels
Augmentation

image augmentations of a matrix, data frame, array or a list of 3-dimensional arrays (where the third dimension is equal to 3)
GaborFeatureExtract

Gabor Feature Extraction
superpixel_bbox_subset

Bounding box for a subset of superpixel labels
dilationErosion

Dilation or Erosion of an image
down_sample_image

downsampling an image ( by a factor ) using gaussian blur
imageShow

display an image
getAffineTransform

Get Affine Transform
invariant_hash

invariant hashing (caclulation of the hamming or the levenshtein distance when the image is flipped, rotated or cropped)
hash_apply

calculate the binary or the hexadecimal hash for a matrix, array or a folder of images for the average_hash, phash or dhash functions
image_thresholding

image thresholding
rotateImage

Rotate an image using the 'nearest' or 'bilinear' method
laplacian_kernels

laplacian kernels
norm_matrix_range

Normalize a matrix to specific range of values
superpixels

SLIC and SLICO superpixel implementations
switch_filter

secondary function for edge_detection function
padding

Padding of matrices or n-dimensional arrays with a user specified value
uniform_filter

uniform filter (convolution with uniform kernel)
translation

image translation
phash

calculation of the 'phash' of an image
runUI

launcher for the shiny application
switch_hashing

if-else function for hashing
verify_image_extension

Verify that the input image extension is valid
switch_invariant

secondary function for invariant_hash
warpAffine

Warp Affine