Learn R Programming

⚠️There's a newer version (1.3.0) of this package.Take me there.

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 devtools package,


devtools::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)]]
// [[Rcpp::plugins(cpp11)]]

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::plugins(cpp11)]]


// [[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 www.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.

Copy Link

Version

Install

install.packages('OpenImageR')

Monthly Downloads

1,785

Version

1.1.7

License

GPL-3

Issues

Pull Requests

Stars

Forks

Last Published

June 18th, 2020

Functions in OpenImageR (1.1.7)

MinMaxObject

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

zca whiten of an image
List_2_Array

convert a list of matrices to an array of matrices
RGB_to_HSV

Conversion of RGB to HSV colour type
RGB_to_Lab

Conversion of RGB to Lab colour type
NormalizeObject

normalize a vector, matrix or array (in the range between 0 and 1)
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
Augmentation

image augmentations of a matrix, data frame, array or a list of 3-dimensional arrays
flipImage

flip image horizontally or vertically
func_transform

secondary function for HOG_apply
GaborFeatureExtract

Gabor Feature Extraction
gamma_correction

Gamma correction
laplacian_kernels

laplacian kernels
cropImage

crop an image
invariant_hash

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

convert an RGB image to Gray
down_sample_image

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

Rotate an image by 90, 180, 270 degrees
crop_image_secondary

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

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

calculation of the 'average hash' of an image
load_binary

loads either 2- or 3-dimensional data from a binary file
edge_detection

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

This function writes 2- or 3-dimensional image data to a file
norm_matrix_range

Normalize a matrix to specific range of values
switch_invariant

secondary function for invariant_hash
convolution

convolution
delationErosion

Delation or Erosion of an image
switch_hashing

if-else function for hashing
dhash

calculation of the 'dhash' of an image
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
gaussian_kernel

gaussian-kernel
padding

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

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

calculation of the 'phash' of an image
sec_gaus_bl

secondary function for downsampling
runUI

launcher for the shiny application
superpixel_bbox_subset

Bounding box for a subset of superpixel labels
superpixel_bbox

Bounding box for the superpixel labels
imageShow

display an image
image_thresholding

image thresholding
sec_resiz_array

secondary function for 'resizeImage' [ array ]
readImage

this function reads various types of images
resizeImage

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

uniform filter (convolution with uniform kernel)
translation

image translation
superpixels

SLIC and SLICO superpixel implementations
switch_filter

secondary function for edge_detection function