Giter Club home page Giter Club logo

openimager's Introduction

tic codecov.io CRAN_Status_Badge Downloads Buy Me A Coffee Dependencies

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},
}

openimager's People

Contributors

mlampros avatar monopteryx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

openimager's Issues

HOG failing for 3D arrays

I am trying to apply the HOG function from OpenImageR_1.1.7 to a 3D array, but it fails with an error message. Here is the log of a small sample program demonstrating the problem:

Script started on Mon 14 Sep 2020 10:19:09 PM CDT
$ ./hog-test.R
[1] "#!/usr/bin/env Rscript"
[2] "system( "cat hog-test.R", intern = T)"
[3] "library( OpenImageR)"
[4] "sessionInfo()"
[5] "Mag <- array( runif( 30), c( 5, 3, 2))"
[6] "cat( "\nclass( Mag):\n")"
[7] "class( Mag)"
[8] "cat( "\ndim( Mag):\n")"
[9] "dim( Mag)"
[10] "cat( "\nMag:\n")"
[11] "print( Mag)"
[12] "cat( "\n")"
[13] "Hog <- try( OpenImageR::HOG( Mag, cells = 3, orientations = 6))"
[14] "if( class( Hog)[ 1] == "try-error") {\t\t# if HOG failed"
[15] " cat( sprintf( "OpenImageR::HOG error %s\n", as.character( Hog)))"
[16] "} else {"
[17] " cat( "Hog: ", Hog, "\n")"
[18] "}"
R version 4.0.1 (2020-06-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] OpenImageR_1.1.7

loaded via a namespace (and not attached):
[1] shiny_1.2.0 compiler_4.0.1 magrittr_1.5 R6_2.4.1
[5] promises_1.0.1 later_0.7.5 htmltools_0.3.6 Rcpp_1.0.4.6
[9] jpeg_0.1-8.1 grid_4.0.1 tiff_0.1-5 digest_0.6.25
[13] xtable_1.8-2 httpuv_1.4.5.1 mime_0.9 png_0.1-7

class( Mag):
[1] "array"

dim( Mag):
[1] 5 3 2

Mag:
, , 1

      [,1]      [,2]      [,3]

[1,] 0.4173635 0.7906940 0.4889265
[2,] 0.8768264 0.9576416 0.6127565
[3,] 0.7443837 0.2411659 0.1802162
[4,] 0.3481922 0.5618764 0.2384123
[5,] 0.6923521 0.1958070 0.5041096

, , 2

      [,1]      [,2]      [,3]

[1,] 0.6272674 0.3110115 0.3748221
[2,] 0.2367036 0.5387666 0.8246165
[3,] 0.2820331 0.9368423 0.9716071
[4,] 0.5958321 0.2095327 0.1982946
[5,] 0.7164110 0.5976341 0.2446890

Error in OpenImageR::HOG(Mag, cells = 3, orientations = 6) :
valid types of input are matrix, data frame and 3-dimensional array
OpenImageR::HOG error Error in OpenImageR::HOG(Mag, cells = 3, orientations = 6) :
valid types of input are matrix, data frame and 3-dimensional array

$ exit
exit

Script done on Mon 14 Sep 2020 10:19:16 PM CDT

Any ideas on what is going wrong?
Thanks.

Segements to polygons?

First of all thank you very much for that neat package. It seems to work fine on my project (detecting desert shrubs in UAV imagery) but I cannot extract the final segments as polygons. Is there any function or trick that I do not know? If not, could you program such a function? I am sure it would be help many more people. Thanks!

superpixels hangs on selected images

Hello,
running superpixels R hangs indefinitely when fed with selected images.
A reproducible example with one such image follows:

library(OpenImageR)
image_m <- structure(c(66, 60, 53, 45, 38, 34, 33, 35, 38, 42, 45, 47, 49, 
                       72, 67, 60, 53, 46, 41, 39, 40, 41, 43, 44, 44, 45, 78, 74, 69, 
                       62, 55, 50, 48, 46, 45, 44, 42, 39, 38, 82, 80, 76, 71, 65, 60, 
                       56, 52, 48, 43, 38, 32, 28, 85, 84, 81, 77, 71, 66, 61, 56, 49, 
                       40, 30, 22, 16, 85, 85, 83, 79, 74, 68, 62, 54, 45, 33, 21, 9, 
                       2, 83, 83, 81, 77, 71, 64, 57, 49, 38, 25, 11, 0, 0, 79, 80, 
                       77, 72, 65, 57, 49, 41, 31, 19, 6, 0, 0, 74, 75, 72, 66, 57, 
                       48, 40, 34, 28, 22, 13, 4, 0, 68, 70, 67, 60, 49, 39, 33, 32, 
                       34, 37, 37, 33, 28, 62, 65, 62, 54, 42, 32, 29, 36, 50, 66, 77, 
                       81, 78, 54, 59, 57, 48, 35, 26, 27, 44, 72, 104, 129, 141, 139, 
                       46, 52, 51, 42, 29, 21, 28, 54, 96, 143, 181, 201, 200, 38, 45, 
                       45, 37, 25, 18, 29, 63, 116, 174, 222, 248, 248, 31, 38, 39, 
                       33, 23, 19, 34, 72, 129, 192, 243, 255, 255, 28, 34, 36, 31, 
                       24, 25, 41, 79, 134, 194, 244, 255, 255, 28, 34, 35, 33, 30, 
                       33, 50, 84, 132, 184, 227, 253, 255), .Dim = c(13L, 17L), .Dimnames = list(
                         NULL, c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", 
                                 "V10", "V11", "V12", "V13", "V14", "V15", "V16", "V17")))
OpenImageR::superpixels(
  image_m,
  method = "slic",
  superpixel = 5,
  compactness = 30,
  return_slic_data = TRUE,
  return_labels    = TRUE,
  write_slic       = "",
  verbose          = TRUE)

In addition, when the same image segmentation is embedded in a Shiny application then a double free or corruption (out) error sometimes appears.

R 4.0.1, OpenImageR 1.1.7.

Thank you.

Bug: average_hash returns inconsistent hash lengths

I have been attempting to use OpenImageR's hash functions in a package designed to facilitate large-scale image comparisons, and everything has been smooth with one major exception.

When I call average_hash with default settings, 95% of the time I get the expected length-64 hash result (in binary mode), while 5% of the time the hash is length-56 (i.e. one row or column of the underlying 8x8 matrix seems to have been dropped), and very occasionally the hash is length-49 (which I imagine means a row AND a column have been dropped).

By comparing these defective hashes with other images which are perceptually identical but bitwise different (and which get the full 64 bits in their hash), it is clear that the last 8 elements of the hash is disappearing. (I.e. the first 56 bits of the two hashes are the same, while one has 8 additional bits and the other simply ends.)

This does not happen with phash, which, in several hundred thousand different tests has always returned a length-64 hash.

I have no idea what is causing this, but I have a reproducible example involving a few images I have uploaded.

library(OpenImageR)

tmp_64 <- tempfile(fileext = ".jpg")
tmp_49 <- tempfile(fileext = ".jpg")

# These are a pair of files which illustrate the issue
download.file("https://upgo.lab.mcgill.ca/resources/hash_test_64.jpg", destfile = tmp_64)
download.file("https://upgo.lab.mcgill.ca/resources/hash_test_49.jpg", destfile = tmp_49)

img_64 <- OpenImageR::readImage(tmp_64)
img_49 <- OpenImageR::readImage(tmp_49)

grey_64 <- rgb_2gray(img_64)
grey_49 <- rgb_2gray(img_49)

# With default arguments, both of these calls should return a length-64 binary hash
hash_64 <- average_hash(grey_64, MODE = "binary")
hash_49 <- average_hash(grey_49, MODE = "binary")

# But this isn't true; the second image is only length-49
length(hash_64) == length(hash_49)

Comparing heatmap images

Dear @mlampros,

I am keen to use OpenImageR to compare two gene expression heatmaps using image hashing. A similar question has been asked at https://stackoverflow.com/questions/43924587/cluster-find-similar-heatmap-figures-using-python.

Eventually, I would like to show the differences/similarities between heatmap images similar to the bar plot shown at https://www.kleemans.ch/comparing-images.
61t

Is there a convenience function to do this with OpenImageR?

Many thanks in advance!

Build fails on Travis-CI

Hello,

I'm using OpenImageR due to the dependency with KernelKnn, and am running into an issue where OpenImageR fails to build on Travis-CI.

See the build log here: https://travis-ci.org/ck37/SuperLearner/builds/198726145#L1023

hog_features.cpp: In function ‘arma::rowvec hog_cpp(arma::mat, int, int)’:
hog_features.cpp:33:60: error: could not convert ‘{{-0x00000000000000001, 0, 1}, {-0x00000000000000002, 0, 2}, {-0x00000000000000001, 0, 1}}’ from ‘<brace-enclosed initializer list>’ to ‘arma::mat {aka arma::Mat<double>}’
hog_features.cpp:34:60: error: could not convert ‘{{-0x00000000000000001, -0x00000000000000002, -0x00000000000000001}, {0, 0, 0}, {1, 2, 1}}’ from ‘<brace-enclosed initializer list>’ to ‘arma::mat {aka arma::Mat<double>}’
make: *** [hog_features.o] Error 1
ERROR: compilation failed for package ‘OpenImageR’

Any ideas? It's working fine in Appveyor so it's hard to say why Travis-CI can't compile it.

Actually, look at the code for KernelKnn, there does not seem to be a need to require OpenImageR as it is only used in a vignette. What about moving OpenImageR to Suggests?
https://github.com/mlampros/KernelKnn/search?utf8=%E2%9C%93&q=OpenImageR

Thanks,
Chris

bad_alloc error

Hi,
I'm willing to run a segmentation on a quite big image (appr. 2Gb) but I'm getting the following error:

error: arma::memory::acquire(): out of memory
Error in interface_superpixels(input_image, method, superpixel, compactness,  : 
  std::bad_alloc

The laptop is new and runs 16 Gb RAM so I don't get how the error can happen. A quick run of memory.limit() reports a limit of 1.759219e+13 so it doesn't look to me as a possible source of troubles.

Any other idea or suggestion?
thanks in advance!

Two test cases in test-norm_matrix_range fail on PowerPC: identical s not TRUE


R version 4.3.0 (2023-04-21) -- "Already Tomorrow"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.8.0 (32-bit)

> library(testthat)
> library(OpenImageR)
> 
> test_check("OpenImageR")

time to complete : 0.02877498 secs 


time to complete : 0.07839799 secs 


time to complete : 0.07635784 secs 


time to complete : 0.07683992 secs 


time to complete : 0.0934062 secs 


time to complete : 0.03983188 secs 


time to complete : 0.002266169 secs 


time to complete : 0.002430916 secs 


time to complete : 0.002615929 secs 


time to complete : 0.007539034 secs 


time to complete : 0.007990122 secs 


time to complete : 0.02551007 secs 


time to complete : 0.01876593 secs 


time to complete : 0.01910877 secs 


time to complete : 0.0005300045 secs 


time to complete : 0.0005509853 secs 


time to complete : 0.0006461143 secs 


time to complete : 0.0005779266 secs 


time to complete : 0.004445076 secs 


time to complete : 0.005106926 secs 


time to complete : 0.009553909 secs 


time to complete : 0.01069307 secs 


time to complete : 0.01310706 secs 


time to complete : 0.0002708435 secs 

[ FAIL 2 | WARN 12 | SKIP 0 | PASS 366 ]

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure ('test-norm_matrix_range.R:61:3'): the 'norm_matrix_range' returns the correct output ( range = c(-1,1) ) ──
identical(res, np_res) is not TRUE

`actual`:   FALSE
`expected`: TRUE 
── Failure ('test-norm_matrix_range.R:70:3'): the 'norm_matrix_range' returns the correct output ( range = c(0,255) ) ──
identical(res, np_res_255) is not TRUE

`actual`:   FALSE
`expected`: TRUE 

[ FAIL 2 | WARN 12 | SKIP 0 | PASS 366 ]
Error: Test failures
Execution halted

Augmentation issue

great project and so cuty the kitty
i have little problem when use the Augmentation function

  1. if i only want to do zcaWhiten but not crop or resize,i will get this error msg:
    zca_comps should be greater or equal to 1 and less than or equal to 0
    i think this is because the initial value of flag_comps is set to be zero,maybe it should be nrow(image)?
  2. when i set crop_width=1:nrow(image),i get this error msg:
    the length of the crop_width sequence should be less than or equal to the initial width of the image
    so maybe "if nrow(image) <= length(crop_width)" should be "if nrow(image) < length(crop_width)", or the msg should be more precise?

imageShow needs path or image object

Dear Lampros,

img <- readImage("test.jpeg")
imageShow(img)  ## does not display image
imageShow("test.jpeg") ## display image

In the vignette, I am trying

path = 'image1.jpeg'
im = readImage(path)
imageShow(im)

Does not work for me

R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.0.5      OpenImageR_1.0.8

loaded via a namespace (and not attached):
 [1] Rook_1.1-1         purrr_0.2.4        colorspace_1.3-2   htmltools_0.3.6   
 [5] viridisLite_0.2.0  yaml_2.1.16        XML_3.98-1.9       rlang_0.1.6       
 [9] pillar_1.1.0       glue_1.2.0         RColorBrewer_1.1-2 bindrcpp_0.2      
[13] jpeg_0.1-8         bindr_0.1          plyr_1.8.4         stringr_1.2.0     
[17] munsell_0.4.3      gtable_0.2.0       visNetwork_2.0.3   htmlwidgets_1.0   
[21] codetools_0.2-15   knitr_1.18         httpuv_1.3.5       DiagrammeR_0.9.2  
[25] Rcpp_0.12.15       xtable_1.8-2       readr_1.1.1        scales_0.5.0      
[29] jsonlite_1.5       rgexf_0.15.3       mime_0.5           gridExtra_2.3     
[33] brew_1.0-6         ggplot2_2.2.1      hms_0.4.1          png_0.1-7         
[37] digest_0.6.14      stringi_1.1.6      tiff_0.1-5         dplyr_0.7.4       
[41] grid_3.4.3         influenceR_0.1.0   tools_3.4.3        magrittr_1.5      
[45] mxnet_0.10.1       lazyeval_0.2.1     tibble_1.4.2       tidyr_0.7.2       
[49] pkgconfig_2.0.1    rsconnect_0.8.5    downloader_0.4     assertthat_0.2.0  
[53] rstudioapi_0.7     viridis_0.4.1      R6_2.2.2           igraph_1.1.2      
[57] compiler_3.4.3   

Thanks,

Metadata retention with rotateFixed function?

Please briefly describe your problem and what output you expect. If you have a question, you also have the option of https://stackoverflow.com/ (but I'm flexible if it's not too complicated)

I'm using the "rotateFixed" function and am wondering if it maintains Jpeg metadata, specifically the "Date/Time created" fields? On rotated images I see correct "Date Created" information when viewing metadata on some platforms (e.g., Lightroom, Bridge), but have had others (e.g., the new Wildlife Insights camera trap platform) not correctly read the original/correct Date/Time metadata.

I'm not necessarily looking for a fix, but just to get confirmation if the code is meant to retain correct metadata after rotation.

Please include a minimal reproducible example

Please give a brief description of the problem

Please add your Operating System (e.g., Windows10, Macintosh, Linux) and the R version that you use (e.g., 3.6.2)
I'm running a new installation of R and RStudio on a new MacBook Pro under OSx 12.1 Monterey.

If my package uses Python (via 'reticulate') then please add also the Python version (e.g., Python 3.8) and the 'reticulate' version (e.g., 1.18.0)

resizeImage mixes up width and height

There is an issue with the resizeImage function where:

  • the resized width is set to the value of the height argument; and, similarly;
  • the resized height is set to the value of the width argument.

An example below.

library(OpenImageR)

# Download a photo of a nice water bottle
url <- "https://www.rei.com/media/269dbba5-dae6-4f57-9053-8a2a7d89925a?size=784x588"
download.file(url,'nalgene.jpg', mode = 'wb')

# Read in image with OpenImageR
image <- readImage("nalgene.jpg")

# Display the dimensions
# Image is 588 high, 325 wide
dim(image)
## [1] 588 325   3

# Resize the image by a factor of 0.5
resized_image <- resizeImage(image = image, 
                             width = dim(image)[2] * 0.5,
                             height = dim(image)[1] * 0.5)

# Display the dimensions of the resized image
# Image is now wider than it is high
dim(resized_image)
## [1] 162 294   3

# Plot the mutated image
plot(as.raster(resized_image))

Screenshot takes one extra color than RGB, could add a function for that?

Hi there,

Thank you for making the package! It looks very promising for so many things!
I am using it, and I noticed that any screenshot would have an extra number in the third dimension of a RGB image. Instead of XY3, screenshots always have XY4. Do you think a function could make such conversion, from screenshot to RGB?

Thank you!
Estella

vignette could add library(grid) as part of instructions

My R skills are not great, so I apologize if this is too obvious and I just didn't learn the proper method.

I suggest that the vignette can be improved by indicating that the system library "grid" should be loaded.

why:
I use RStudio and it does not load 'grid' automatically. While going through the vignette at this stage:

path = file.path(getwd(), 'vignette_1', 'image2.jpg')
im = readImage(path)
thr = image_thresholding(im, thresh = 0.5)           # if the input image is 3-dimensional it will be converted internally to a matrix
imageShow(thr)

I'm hit with the following error for imageShow if I do not pre-load the grid library.

Error: Error converting object to arma::Cube<T>:
Input array must have exactly 3 dimensions.

The reason for this is that thr is a 2D matrix since rgb_2gray() is called. imageShow() then uses grid.raster. While the code used in image_thresholding() does call grid::grid.raster(), if grid isn't loaded into library, the above error is produced.

The only reason I was able to figure this out was because I stumbled across a test somewhere that said "image_thresholding" failed, but it wasn't clear why. I'm afraid I don't know where thatpage is anymore.

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

First tried HOG_apply in OpenImageR on Windows 10, using binary Windows library

Received following message:

X1<- HOG_apply(object="./", cells=3, orientations=6, threads=4)

error: Mat::init(): size is fixed and hence cannot be changed
Error in list_2array_convert(tmp_lst) :
Mat::init(): size is fixed and hence cannot be changed

Question is what is the maximum number of files that HOG_apply can be used with in a directory? I got it to work with 9 files, but when I tried 32 files I got the above message.

Windows 10 Pro build 19042.1288, R version 4.1.1.

Install OpenImageR failed on ubuntu server 16.04 LTS

I install R 3.3.3 on Ubuntu server 16.04 LTS OS, when I install OpenImageR package, I meet below error message, can you help me to reslove this issue? thank you.

* installing *source* package ‘OpenImageR’ ...
** package ‘OpenImageR’ successfully unpacked and MD5 sums checked
** libs
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I../inst/include/ -DU_STATIC_IMPLEMENTATION -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/Rcpp/include" -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/RcppArmadillo/include"  -fopenmp    -c RcppExports.cpp -o RcppExports.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'RcppExports.o' failed
make: [RcppExports.o] Error 127 (ignored)
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I../inst/include/ -DU_STATIC_IMPLEMENTATION -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/Rcpp/include" -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/RcppArmadillo/include"  -fopenmp    -c dilation_erosion_rgb2gray.cpp -o dilation_erosion_rgb2gray.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'dilation_erosion_rgb2gray.o' failed
make: [dilation_erosion_rgb2gray.o] Error 127 (ignored)
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I../inst/include/ -DU_STATIC_IMPLEMENTATION -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/Rcpp/include" -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/RcppArmadillo/include"  -fopenmp    -c hog_features.cpp -o hog_features.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'hog_features.o' failed
make: [hog_features.o] Error 127 (ignored)
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I../inst/include/ -DU_STATIC_IMPLEMENTATION -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/Rcpp/include" -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/RcppArmadillo/include"  -fopenmp    -c image_hashing.cpp -o image_hashing.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'image_hashing.o' failed
make: [image_hashing.o] Error 127 (ignored)
I/usr/lib64/microsoft-r/3.3/lib64/R/include -DNDEBUG -I../inst/include/ -DU_STATIC_IMPLEMENTATION -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/Rcpp/include" -I"/usr/lib64/microsoft-r/3.3/lib64/R/library/RcppArmadillo/include"  -fopenmp    -c utils.cpp -o utils.o
sh: I/usr/lib64/microsoft-r/3.3/lib64/R/include: No such file or directory
/usr/lib64/microsoft-r/3.3/lib64/R/etc/Makeconf:141: recipe for target 'utils.o' failed
make: [utils.o] Error 127 (ignored)
-shared -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -o OpenImageR.so RcppExports.o dilation_erosion_rgb2gray.o hog_features.o image_hashing.o utils.o -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -lRlapack -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -lRblas -lgfortran -lm -fopenmp -L/usr/lib64/microsoft-r/3.3/lib64/R/lib -lR
sh: line 2: -shared: command not found
/usr/lib64/microsoft-r/3.3/lib64/R/share/make/shlib.mk:6: recipe for target 'OpenImageR.so' failed
make: *** [OpenImageR.so] Error 127
ERROR: compilation failed for package ‘OpenImageR’
* removing ‘/usr/lib64/microsoft-r/3.3/lib64/R/library/OpenImageR’

Error in documentation of rotateImage angle argument

In the section in the reference manual for the rotateImage function in OpenImageR version 1.1.2, the angle argument is described as "specifies the number of radians". In fact angle is interpreted as degrees, not radians.

imageShow

imageShow used to display grayscale images. However, currently it only displays RGB images and cannot display grayscale images.

supported image types are case sensitive

Hi,

I am trying to calculate hash values for JPG images, but OpenImageR::readImage is case sensitive and returns an error: supported image types are .png, .jpeg, .jpg, .tiff (or .tif, .TIFF, .TIF)

I understand that modifying the file extension would work, but perhaps the readImage() function could simply ignore case sensitive in the exception for the supported image types. For example:

if (isTRUE(grepl(x = flag_type, pattern = c("jpeg|jpg"), ignore.case = TRUE))){
  img = jpeg::readJPEG(path)
}

System: R 4.2.2 on x86_64-pc-linux-gnu. OpenImageR_1.2.7 and jpeg_0.1-10.

Thanks for the great work.

resizeImage(...) for unbound values

Hello, I found some difficulty with using resizeImage(...) for a geometrically warped image. I was performing image registration via RNiftyReg package and their transformation slightly change the pixel values from (0, 1) to (0, 1.09). This case that the resized image is just black/white with a few dots. In the end clip image values to the range (0, 1) solves the issue but it quite unintuitive what and why the resize returns unexpected results...

Augmentation when shift_row or shift_col is negative.

Hi, I find a weird behavior of Augmentation when shift_rows or shift_cols is negative.

library(OpenImageR)
a <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.157887008553284, 
0.506956425975552, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 
0.783377996402482, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.848940934620609, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.836092654454682, 
0.434308578980214, 0.434308578980214, 0.434308578980214, 0.434308578980214, 
0.434308578980214, 0.434308578980214, 0.434308578980214, 0.434308578980214, 
0.434308578980214, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.157887008553284, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(15L, 10L))

b <- Augmentation(a, shift_rows=-1, shift_cols=-1)
b
#      [,1] [,2]      [,3]     [,4]      [,5]      [,6] [,7]     [,8] [,9] [,10]
# [1,]    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000    1     1
# [2,]    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000    1     1
# [3,]    1    1 1.0000000 1.000000 0.8489409 0.8360927    1 1.000000    1     1
# [4,]    1    1 0.1578870 0.000000 0.0000000 0.4343086    1 1.000000    1     1
# [5,]    1    1 0.5069564 0.783378 0.0000000 0.4343086    1 1.000000    1     1
# [6,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
# [7,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
# [8,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
# [9,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
#[10,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
#[11,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
#[12,]    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000    1     1
#[13,]    1    1 0.0000000 0.000000 0.0000000 0.0000000    0 0.157887    1     1
#[14,]    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000    1     1
#[15,]    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000    1     1
all(a==b)
# TRUE

So, no change in the image at all.
It seems the function discounts shift_rows and shift_cols by 1 when it is negative. That is, it treats -1 as 0, -2 as -1, and so on.

ignore values

i'm trying to use edge_detection() to detect snow line in a satellite image but I would like to ignore pixels classified as clouds or water. when i tried to set clouds or water to NA there is an error. i would only like to detect the edge between snow cover and bare ground. Is there another way to ignore a value in the detection algorithm?

imagehash

Hi! Cool to see imagehash re-implemented in R. I was wondering if you would consider adding a reference back to the original project. You might also want to check the latest version, we fixed some bugs (see Changelog). Cheers!

Default values for shifted images by Augmentation?

Hi, I have a matrix representing a gray-scale image like below.
In this matrix, 0 represents black and 1 represents white.

a <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.157887008553284, 
0.506956425975552, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 
0.783377996402482, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0.848940934620609, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.836092654454682, 
0.434308578980214, 0.434308578980214, 0.434308578980214, 0.434308578980214, 
0.434308578980214, 0.434308578980214, 0.434308578980214, 0.434308578980214, 
0.434308578980214, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.157887008553284, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(15L, 10L))

This looks like
1

When I used Augmentation function with shift_rows or shift_cols options, I get the following.

library(OpenImageR)
Augmentation(a, shift_rows=2, shift_cols=-2)
#        [,1]  [,2] [,3]      [,4]     [,5]      [,6]      [,7] [,8]     [,9] [,10]
#  [1,]    0    1    1 1.0000000 1.000000 0.8489409 0.8360927    1 1.000000     1
#  [2,]    0    1    1 0.1578870 0.000000 0.0000000 0.4343086    1 1.000000     1
#  [3,]    0    1    1 0.5069564 0.783378 0.0000000 0.4343086    1 1.000000     1
#  [4,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
#  [5,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
#  [6,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
#  [7,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
#  [8,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
#  [9,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
# [10,]    0    1    1 1.0000000 1.000000 0.0000000 0.4343086    1 1.000000     1
# [11,]    0    1    1 0.0000000 0.000000 0.0000000 0.0000000    0 0.157887     1
# [12,]    0    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000     1
# [13,]    0    1    1 1.0000000 1.000000 1.0000000 1.0000000    1 1.000000     1
# [14,]    0    0    0 0.0000000 0.000000 0.0000000 0.0000000    0 0.000000     0
# [15,]    0    0    0 0.0000000 0.000000 0.0000000 0.0000000    0 0.000000     0

This looks like below.
1b

So, the padded value is always 0, where I want to use 1 to fill and I could not find a way to choose it.
It would be great if I can freely chose the default value to be filled in.

Thanks.

OpenInmageR installation error

Compilation failed in Windows machine(with R version 3.2.2) even after installing Rtools and Rcpp.Is this package not ready for Windows OS?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.