Fecha actual Jue Nov 21, 2024 1:51 pm
Moderadores: IOM60, laucsap60, klomp, Siniestro, Guillermo Luijk, Pablo Valido
Relative exposures (EV): 3.02 6.02
Data participating in relative exposure calculation (%): 10.01 30.84
Contribution of raw1.tiff: 20.21%
Contribution of raw2.tiff: 16.67%
Contribution of raw3.tiff: 63.12%
library(tiff)
# PARAMETERS
N=3 # number of RAW files to merge
NAME="raw" # RAW filenames
gamma=1 # output gamma
# NOTE: only gamma=1 guarantees correct colours but could lead to posterization
# READ RAW DATA
# RAW files must be named: raw1.dng, raw2.dng,... from lower to higher exposure
# RAW extraction using DCRAW: dcraw -v -d -r 1 1 1 1 -S 16376 -4 -T *.dng
img=list()
txt=list()
for (i in 1:N) {
img[[i]]=readTIFF(paste0(NAME, i, ".tiff"), native=F, convert=F)
txt[[i]]=paste0(NAME, i, "vs", NAME, i+1)
}
# RELATIVE EXPOSURE CALCULATIONS
MIN=2^(-5) # from -5EV... (NOTE: MIN must be >= bracketing EV intervals)
MAX=0.95 # ...up to 95%
indices=list()
exprel=list()
f=array(-1, N-1)
for (i in 1:(N-1)) {
indices[[i]]=which(img[[i]]>=MIN & img[[i]]<=MAX &
img[[i+1]]>=MIN & img[[i+1]]<=MAX)
exprel[[i]]=img[[i+1]][indices[[i]]]/img[[i]][indices[[i]]]
f[i]=median(exprel[[i]]) # linear exposure correction factor
}
print("Relative exposures vs lowest exposure shot (EV):")
print(round(log(cumprod(f),2),2))
# Relative exposure histograms
png("relexposure_histogram.png", width=640, height=320*(N-1))
par(mfrow=c(N-1,1))
for (i in 1:(N-1)) {
flog=log(f[i],2)
rflog=round(flog)
exprelog=log(exprel[[i]],2)
hist(exprelog[exprelog>=rflog-1/3 & exprelog<=rflog+1/3],
main=paste0('Relative exposure histogram (', txt[[i]], ')'),
xlab=paste0('EV (calculated: ', round(flog,2), 'EV)'),
breaks=seq(rflog-1/3, rflog+1/3, length.out=800)
)
abline(v=flog, col='red') # calculated relative exposure
abline(v=rflog, col='gray', lty='dotted') # closest int EV mark
}
dev.off()
# Relative exposure calculation map
solape=array(-1, N-1)
for (i in 1:(N-1)) {
mapacalc=img[[i]]*0
mapacalc[indices[[i]]]=1 # 1=pixel participated in the calculation
writeTIFF(mapacalc, paste0("mapacalc_", txt[[i]], ".tif"),
bits.per.sample=8, compression="LZW")
solape[i]=length(indices[[i]])/length(img[[i]]) # % of data participating
}
print("Data participating in relative exposure calculation (%):")
print(round(solape*100,2))
# BUILD HDR COMPOSITE
hdr=img[[1]] # start with lowest exposure
mapafusion=img[[i]]*0+1
for (i in 2:N) {
indices=which(img[[i]]<=MAX) # non-clipped highest exposure
hdr[indices]=img[[i]][indices]/cumprod(f)[i-1] # overwrite+exp correction
mapafusion[indices]=i
}
if (max(hdr)<1) print(paste0("Output ETTR'ed by: +",
round(-log(max(hdr),2),2), "EV"))
writeTIFF((hdr/max(hdr))^(1/gamma), "hdr.tif", bits.per.sample=16,
compression="none")
# Fusion map and RAW data files contributions
writeTIFF((mapafusion-1)/(N-1), "mapafusion.tif",
bits.per.sample=8, compression="LZW")
for (i in 1:N) print(paste0("Contribution of ", NAME, i, ".tiff: ",
round(length(which(mapafusion==i))/length(mapafusion)*100,2),"%"))
# Bit decimation
# 10, 12, 14 bits versions -> 1024, 4096, 16384 levels
for (bits in seq(10,14,2)) {
hdr2=round(hdr*(2^bits-1))
writeTIFF((hdr2/max(hdr2))^(1/gamma), paste0("hdr_",bits,"bits.tif"),
bits.per.sample=16, compression="none")
}
Rafa18 escribió:Para generar el RAW-HDR ¿Cómo haces las tomas?
¿Expones al 0 y luego haces las siguientes fotos exponiendo a +1, +2, etc. o cómo?
¿Se podría hacer el proceso de fusionar los RAWs bajo Linux?
exiftool -shutterspeed *.dng
======== _DSC3845.dng
Shutter Speed : 1/3200
======== _DSC3846.dng
Shutter Speed : 1/400
======== _DSC3847.dng
Shutter Speed : 1/50
======== _DSC3848.dng
Shutter Speed : 1/6
======== _DSC3849.dng
Shutter Speed : 1.3
JMLA escribió:no sé en qué es diferente esta propuesta, o qué es lo que me he perdido.
Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 51 invitados