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 Vignettes and in the package Documentation.

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(arma::cube RGB_image) {

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

Then, by opening an R file a user can call the rgb_2gray 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(im_rgb)

str(im_grey)

Use the following link to report bugs/issues,

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

Copy Link

Version

Install

install.packages('OpenImageR')

Monthly Downloads

2,328

Version

1.1.4

License

GPL-3

Issues

Pull Requests

Stars

Forks

Last Published

January 7th, 2019

Functions in OpenImageR (1.1.4)

NormalizeObject

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

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

load 3-dimensional data from a binary file
Augmentation

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

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

normalize in specific range of values
rgb_2gray

convert an RGB image to Gray
GaborFeatureExtract

Gabor Feature Extraction
flipImage

flip image horizontally or vertically
func_chech_range

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

gaussian-kernel
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
sec_resiz_array

secondary function for 'resizeImage' [ array ]
HOG

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

SLIC and SLICO superpixel implementations
delationErosion

Delation or Erosion of an image
dhash

calculation of the 'dhash' of an image
HOG_apply

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

secondary function for invariant_hash
cropImage

crop an image
translation

image translation
crop_image_secondary

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

zca whiten of an image
RGB_to_Lab

Conversion of RGB to Lab colour type
invariant_hash

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

calculation of the 'phash' of an image
laplacian_kernels

laplacian kernels
readImage

this function reads various types of images
imageShow

display an image
image_thresholding

image thresholding
rotateFixed

Rotate an image by 90, 180, 270 degrees
rotateImage

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

secondary function for edge_detection function
switch_hashing

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

calculation of the 'average hash' of an image
convolution

convolution
func_transform

secondary function for HOG_apply
gamma_correction

Gamma correction
runUI

launcher for the shiny application
sec_gaus_bl

secondary function for downsampling
uniform_filter

uniform filter (convolution with uniform kernel)
writeImage

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

Conversion of RGB to HSV colour type
down_sample_image

downsampling an image ( by a factor ) using gaussian blur