Skip to content

Instantly share code, notes, and snippets.

MenuHandler.prototype.buildMenu = function(menuObj, MaxLevels, currLevel, basePath) {
var menu = "", menuItem, className, extraTitle;
for (var childMenuKey in menuObj) {
menuItem = '';
className = '';
extraTitle = "";
if ( !/[^\-—–\s]/.test( menuObj[childMenuKey].menu ) )
menuItem = '---';
@oscardelama
oscardelama / rgb-noise: selecting few samples.r
Last active August 29, 2015 14:14
rgb-noise: Select samples
# 1) Read and digest the channels with valid values
vvm.all <- vvm$new(has.RGGB.pattern = TRUE)
vvm.all$digest(
file.name.from = '_ODL0387s4',
file.name.to = '_ODL1671s6',
file.name.ext = '.pgm',
file.path = 'ISO100/crops',
min.raw = 4,
max.raw = c(16379, 15774, 15774 ,16379))
@oscardelama
oscardelama / gist:259b3e9715819a76be9f
Last active August 29, 2015 14:14
rgb-noise: vvm initial Analysis
library(imgnoiser)
vvm.all <- vvm$new(has.RGGB.pattern = TRUE)
vvm.all$digest(file.name.from = '_ODL0387s4',
file.name.to = '_ODL1671s6',
file.name.ext = '.pgm',
file.path = 'ISO100/crops',
min.raw = 4, # <= Raising this limit to avoid the funny red tail
max.raw = c(16379, 15776, 15776 ,16379))
# Fit a quadratic, weighted, robust model
@oscardelama
oscardelama / gist:773e45301580c7d9e6c3
Last active August 29, 2015 14:14
rgb-noise: digest as RGB each set
# Convert selected raw images to a given destinations space
# without demosaicing
convert.to.rgb <- function(target.space,
use.camera.tc,
target.tc,
cam.coldata = imgnoiser::nikon.d7000.ISO100.colmap,
dest.scale = 255
) {
library(imgnoiser)
@oscardelama
oscardelama / gist:b6ef41fcadf53c1a971a
Last active August 29, 2015 14:14
rgb-noise: hvdvm initial analysis
hvm.all <- hvdvm$new(has.RGGB.pattern = TRUE)
hvm.all$digest(photo.conds.file = 'ISO100/crops/full-set.csv',
crop.files.path = 'ISO100/crops',
min.raw = 4,
max.raw = c(16379, 15774, 15774 ,16379))
# Fit a quadratic model
hvm.all$fit.model(model.name = 'weighted',
model.family = 'lmrob',
degree = 2,
@oscardelama
oscardelama / gist:2340a92e91bcf3de6fd6
Last active August 29, 2015 14:14
rgb-noise: Checking the selected good samples
# Read the selected 'good' image sample file names
sel.pics <- read.csv('sel-pict.csv')
vvm.sel <- vvm$new(has.RGGB.pattern = TRUE)
# 'Digest' the samples computing noise related statistics
vvm.sel$digest(
file.name.from = sel.pics$pict,
file.path = 'ISO100/Selection/crops'
)
@oscardelama
oscardelama / gist:9f1a52e7017666011be6
Last active August 29, 2015 14:14
rgb-noise: Scale function from linear sRGB to Lightroom sRGB
# Get the LR tifs var data
tif.var.zero <- vvm.tif$var.df
# Rename 'mean' and 'var' columns to avoid later name colision in merging
names(tif.var.zero)[3:4] <- paste0('tif.', names(tif.var.zero)[3:4])
# Remove sample file name extension to make possible the merge by picture file name
tif.var.zero$pict <- substr(tif.var.zero$pict, 1, 8)
# Compute the linear sRGB values
vvm.rgb.lin <- convert.to.rgb(target.space = 'sRGB', use.camera.tc = FALSE, target.tc = 'linear')
# Get the sRGB linear wide var data
@oscardelama
oscardelama / rgb-noise: Get spline approx to LR camera TC.r
Last active August 29, 2015 14:14
rgb-noise: Build a spline approximation to the Lightroom camera tone curve
# Plot log-log of LR and our camera tone curves
ggplot(lin.rgb.and.tif) +
geom_point(aes(x = (mean)/255, y = tif.mean.cam/255,
group = channel, colour = channel),
size = 1.5) +
ggtitle('LR Camera tone curve\nFor Nikon D7000') +
xlab('linear sRGB gray (log10)') + ylab('LR camera TC sRGB gray (log10)') +
scale_x_log10() +
scale_y_log10() +
geom_line(aes(x=x, y=y), data=my.cam.tc, color='darkblue', linetype='dashed')
@oscardelama
oscardelama / gist:bd2f949fd9295ca2a9b5
Created February 6, 2015 16:44
rgb-noise: sRGB linear - Initial analysis
vvm.rgb <- convert.to.rgb(target.space = 'sRGB', use.camera.tc = FALSE, target.tc = 'linear')
x11()
vvm.rgb$plot(tlab = "VVM Selected samples in linear sRGB",
slab = 'Without camera tone curve')
vvm.rgb$plot(x = log2(mean), y = 20*log10(mean/sqrt(var)),
tlab = "SNR Selected samples in linear sRGB",
slab = 'Without camera tone curve',
xlab = "Signal (stops)", xlim=c(-1.5,8),
ylab = "SNR (dB)")
@oscardelama
oscardelama / gist:d85a5fe11db274aa1103
Last active August 29, 2015 14:14
rgb-noise: Condense the three raw noise models in one
library(imgnoiser)
library(ggplot2)
# Y coordinate of sRGB primaries. From http://en.wikipedia.org/wiki/SRGB
weights.sRGB <- c(0.2126, 0.7152, 0.0722)
# D65 white point in XYZ. From ASTM E308-01 in http://www.brucelindbloom.com/
D65.XYZ <- c(0.95047, 1.00000, 1.08883)
# With "D65 color matrix" in the camera color data, we can convert
# the D65 XYZ white point to the camera raw color space:
D65.raw <- nikon.d7000.ISO100.colmap$cam.matrices.2$color.matrix %*% D65.XYZ
#> [,1]