r - Improve speed of color conversion from sRGB to Lab -


i need convert high-resolution ortho-mosaic photos srgb lab color space. i've tried using base r function convertcolor() i've never accomplished @ least 1 conversion (images on 10 hectares 5cm pixel resolution, ~50.0000.0000 pixels).

i tried patchplot package, has faster computation. but, considering size of images i'm looking better way it.

is there package / function / method improve computation?

example test convertcolor , patchplot::rgb2lab:

library(raster) library(patchplot) library(microbenchmark)  r <- stack(system.file("external/rlogo.grd", package="raster"))  microbenchmark(baser = convertcolor(color = values(r), = 'srgb', = 'lab'),                patchplot = rgb2lab(values(r))) ## unit: milliseconds ##       expr        min        lq      mean    median        uq       max neval cld ##      baser 261.702873 282.60345 316.76008 310.31006 327.05536 550.07653   100   b ##  patchplot   8.335807   9.58279  11.53369  10.11684  11.69073  46.78427   100   

this far perfect solution, can try improve it. thing can play around nmatrix (into how many matrices want split original rgb matrix).

library(microbenchmark) library(parallel) library(patchplot) library(raster)  # how many matrices want have nmatrix <- 4  # load raster r <- stack(system.file("external/rlogo.grd", package = "raster")) # extract value matrix rvalues <- values(r) n <- nrow(rvalues)  # groups split rvalues nmatrix parts foo <- rep(1:nmatrix, each = ceiling(n / nmatrix)) # if group vector exceeds number of rows in matrix trim if (length(foo) > n) {     foo <- foo[1:n] } # splitted matrices rvaluessplit <- lapply(split(rvalues, foo), matrix, ncol = 3)  microbenchmark(do.call(rbind,mclapply(rvaluessplit, rgb2lab, mc.cores = 1))) 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -