img_2_data | R Documentation |
Inputs a PNG image and return the grayscale matrix along with the individual channels separated.
The input PNG images are normally classified into RGB, RGBA, G/grayscale or GA types.
The grayscale matrix could also be plotted.
img_2_data(source.png, x.lim, y.lim, pl = T, bgrnd = 1)
img_2_data(source.png, x.lim, y.lim)
img_2_data(source.png, x.lim, y.lim, bgrnd = 0.5)
img_2_data(source.png, x.lim, y.lim, pl = F)
source.png |
Path leading to the PNG file |
x.lim |
The x-limits of the image. |
y.lim |
The y-limits of the image. |
pl |
Boolean bit, set to TRUE by default. |
bgrnd |
Numeric scalar, set to 1 by default. |
The returned value is always a two-element list.
The first element in the list is "gray.val" which is the grayscale matrix.
The second element of the list is "data".
"data" itself is a list which contains the matrixes pertaining to the different channels of the original PNG image, like red, green, blue and alpha in case of an RGBA image.
Chitran Ghosal
library(StatsChitran)
dat <- system.file("extdata", "asymmetry.png", package = "StatsChitran")
L <- img_2_data(source.png = dat, x.lim = c(0, 7), y.lim = c(0, 3), bgrnd = 0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.