GA_2_gray | R Documentation |
Converts GA values in R numeric formats to grayscale values of the same format
GA_2_gray(gray.ch, alp.ch)
GA_2_gray(gray.ch, alp.ch, bg = 1)
GA_2_gray(gray.ch, alp.ch, bg = 0)
gray.ch |
The gray channel of the data that you want to convert. |
alp.ch |
This argument denotes the transparency of the GA data. |
bg |
This argument has to be a single number between 0 and 1. |
gray.ch and alp.ch, can be have structures of matrix, vectors(NOT lists) and arrays.
gray.ch and alp.ch all need to have the same structures and dimensions.
Dataframes will not be handled.
The return value will have the same structure and dimension of gray.ch and alp.ch.
It will defintely be a numeric as non-numeric values are not entertained as inputs.
The gray values are defined as shown below......
gray_val <- alp.ch*gray_val + (1 - alp.ch)*bg
Chitran Ghosal
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or standard data sets, see data().
#write a program to test RGBA_2_Gray
library(StatsChitran)
#define the GA array
arr <- array(data = runif(n = 2*10^4, min = 0, max = 1), dim = c(100, 100, 2))
#define the X and the Y values
X <- seq(1, 100)
Y <- seq(1, 100)
#call the GA_2_gray values with different backgrounds
M1 <- GA_2_gray(gray.ch = arr[,,1], alp.ch = arr[,,2]) #white background
M2 <- GA_2_gray(gray.ch = arr[,,1], alp.ch = arr[,,2], bg = 0) #black background
#plot the results
subplot(c(2, 1))
plot2D.mat(X, Y, Z = M1)
plot2D.mat(X, Y, Z = M2)
subplot(c(1, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.