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
# Draw SNR quality reference limits for 18% gray | |
add.snr.ref.limits <- function(p) { | |
p + | |
geom_hline(aes(yintercept=20), colour='red', linetype = 6, alpha = 0.4) + | |
geom_hline(aes(yintercept=32), colour='cyan', linetype = 6, alpha = 0.8) + | |
geom_hline(aes(yintercept=38), colour='green', linetype = 6, alpha = 0.8) | |
} |
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
# Read the TIFF files | |
vvm.tif <- vvm$new(has.RGGB.pattern = TRUE) | |
vvm.tif$digest.from.rgb( | |
file.name.from = '_ODL0415', | |
file.name.to = '_ODL1668', | |
file.path = 'ISO100/Selection/LR-zero' | |
) | |
# VVM plot | |
vvm.tif$plot(tlab = "VVM: sRGB images from Lightroom", | |
slab = 'With zero settings', |
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); |
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
library(imgnoiser) | |
library(dplyr) | |
library(robustbase) | |
# Acquire the data | |
vvm.all <- vvm$new(has.RGGB.pattern = TRUE) | |
vvm.all$digest( | |
file.name.from = '_ODL0387s4', | |
file.name.to = '_ODL1671s6', | |
file.name.ext = '.pgm', |
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
# Compute the SNR. | |
# Returns "high" values when the model variance is negative to | |
# hint the optimizer to get out of there. | |
snr <- function(mean, var) { | |
negatives <- which(var < 0) | |
result <- 20*log10(mean/sqrt(abs(var))) | |
result[negatives] <- result[negatives]*8 | |
result; | |
} |
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
# Get the weighted errors `w.mean` and `w.var` | |
test.error.weighted.var <- function(sel.channel, coeffs) { | |
tests.pics <- read.csv('test-pics.csv', stringsAsFactors = FALSE, row.names=NULL) | |
tests.pics <- as.vector(tests.pics[,1]) | |
data.df <- subset(data.frame(vvm.all$var.df), | |
channel == sel.channel & | |
pict %in% tests.pics) | |
predicted.var <- (data.df$mean*coeffs[3] + coeffs[2])*data.df$mean + coeffs[1] | |
error.var <- mean((data.df$var - predicted.var)^2/predicted.var) |
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
execute.tests <- function(n) { | |
# A place-holder for the test results | |
result.df <- data.frame() | |
# Initial values for snr model optimization | |
param.init <- c(2, 0.4, 5e-06) | |
# Iterate n times | |
for (n in 1:n) { | |
split.data() | |
# Model each channel per iteration |
OlderNewer