Last active
August 29, 2015 14:15
-
-
Save oscardelama/084b6c68a0c0cfd0349f to your computer and use it in GitHub Desktop.
Compute the loss of SNR we converting a raw image to a RGB color space.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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