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 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 = {2022},
  note = {R package version 1.2.4},
  url = {https://CRAN.R-project.org/package=OpenImageR},
}

Copy Link

Version

Install

install.packages('OpenImageR')

Monthly Downloads

1,683

Version

1.2.4

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Lampros Mouselimis

Last Published

August 17th, 2022

Functions in OpenImageR (1.2.4)

HOG

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

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

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

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

gaussian-kernel
dhash

calculation of the 'dhash' of an image
image_thresholding

image thresholding
getAffineTransform

Get Affine Transform
delationErosion

Delation or Erosion of an image
invariant_hash

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

Normalize a matrix to specific range of values
RGB_to_HSV

Conversion of RGB to HSV colour type
RGB_to_Lab

Conversion of RGB to Lab colour type
switch_filter

secondary function for edge_detection function
writeImage

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

flip image horizontally or vertically
switch_hashing

if-else function for hashing
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
func_chech_range

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

display an image
average_hash

calculation of the 'average hash' of an image
padding

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

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

convert an RGB image to Gray
superpixel_bbox_subset

Bounding box for a subset of superpixel labels
uniform_filter

uniform filter (convolution with uniform kernel)
convolution

convolution
warpAffine

Warp Affine
func_transform

secondary function for HOG_apply
crop_image_secondary

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

zca whiten of an image
cropImage

crop an image
laplacian_kernels

laplacian kernels
runUI

launcher for the shiny application
sec_gaus_bl

secondary function for downsampling
translation

image translation
gamma_correction

Gamma correction
switch_invariant

secondary function for invariant_hash
superpixels

SLIC and SLICO superpixel implementations
phash

calculation of the 'phash' of an image
load_binary

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

Rotate an image by 90, 180, 270 degrees
readImage

this function reads various types of images
sec_resiz_array

secondary function for 'resizeImage' [ array ]
superpixel_bbox

Bounding box for the superpixel labels
rotateImage

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

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

convert a list of matrices to an array of matrices
GaborFeatureExtract

Gabor Feature Extraction
NormalizeObject

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

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