Skip to content

Instantly share code, notes, and snippets.

@oscardelama oscardelama/loss-of-snr.r

Last active Aug 29, 2015
Embed
What would you like to do?
Compute the loss of SNR we converting a raw image to a RGB color space.
avg.loss.of.snr <- function(color.conv.matrix, white.bal.scales) {
sqr.conv.mtx <- color.conv.matrix^2
wb.conv.mtx <- t(apply(sqr.conv.mtx, 1, function(x) x*white.bal.scales ))
mc <- apply(wb.conv.mtx, 1, sum)
loss <- mean(log10(mc)) - mean(log(white.bal.scales) )
# Result
10*loss;
}
# Helper function to build the color matrix
matrix_3x3 <- function(x) matrix(x, nrow=3L, ncol=3L, byrow=TRUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.