How to extract RGB DNs from an image using R? -


enter image description here

this sample image fish eye lens camera. want extract digital number image further research.

how extract rgb dns image using r?

the optimal approach differ depending on overall aim is. started, try functionality provided package ebimage, general-purpose image processing , analysis toolbox applications in bioimage analysis. provides functions load images r, , perform various image transformations , filtering. example below illustrates how load sample image , draw histogram. see package vignette details on image data representation, , overview of provided functionality.

# package installation form biocondcutor # need run once source("https://bioconductor.org/bioclite.r") bioclite("ebimage")  library("ebimage") img <- readimage("https://i.stack.imgur.com/jtswo.jpg")  ## image  ##   colormode    : color  ##   storage.mode : double  ##   dim          : 1500 1001 3  ##   frames.total : 3  ##   frames.render: 1  ##  ## imagedata(object)[1:5,1:6,1] ##            [,1]       [,2]       [,3]       [,4]       [,5]       [,6] ## [1,] 0.05098039 0.09019608 0.04705882 0.00000000 0.02352941 0.02745098 ## [2,] 0.06274510 0.09411765 0.05490196 0.01176471 0.02745098 0.02745098 ## [3,] 0.06274510 0.08235294 0.05098039 0.01960784 0.02745098 0.02352941 ## [4,] 0.04705882 0.05098039 0.03529412 0.01960784 0.01960784 0.01960784 ## [5,] 0.02352941 0.01176471 0.01176471 0.01960784 0.01176471 0.01176471  hist(img) 

enter image description here

for example, can calculate mean pixel intensity value each color channel applying function on 3rd image dimension.

apply(img, 3, mean)  ## [1] 0.2216768 0.2592197 0.1629841 

these values correspond average pixel values in red, green , blue color channels, respectively. pixel values normalized [0, 1] range, these numbers represent fractions of respective colors in image. note if interested in reliably comparing images taken @ same spot @ different time points should make sure taken same fixed value of white balance.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -