# Last edited on 2010-06-27 12:50:56 by stolfi GOAL Investigate the non-uniformities of the imaging response of the AVT Pike F-100 camera made available to Rafael Saracchini at MVL-UWE in may-jun 2010. The main sources of non-uniformity seem to be: (1) Vignetting by the lens. Should have radial symmetry. (2) Variation in pixel gains. There seem to be both high- and low-frequency variations. (3) Gain difference between the two sensor output amplifiers used for left and right halves of the image. Item (3) the difference in brightness between the two halves of the sensor was corrected by setting the gains of the two output amplifiers to the same value (the default was wrong). Now we will try to extract a white mask to compensate for (1) and (2). PROCEDURE Rafael at UWE took some images of a paper sheet with unfocused lens and LED-1 lamp, with light source at various azimuths and with various shutter times. The Pike F-100 RAW16 images have been fecthed and renamed (see "data/wget-images.sh"). The names are "data/t-${light}-${shutter}.raw" where ${light} is "a000d0" azimuth 0 inclination 25 degrees "a090d0" azimuth 90 inclination 25 degrees "a180d0" azimuth 180 inclination 25 degrees "a180d2" azimuth 180 inclination 25 degrees with paper displaced 2cm lights=( "a000d0" "a090d0" "a180d0" "a180d2" ) The first three sets were obtained with the paper sheet and camera at exactly the same position. The ${shutter} parameter is shutters=( "s4095" "s3072" "s2048" "s1024" ) Extracting the Bayer channels split into two halves: for light in ${lights[@]} ; do for shutter in ${shutters[@]} ; do for chn in G0 G1 R0 B0 ; do piketopnm -crop 0 0 502 1000 -extract ${chn} \ < data/t-${light}-${shutter}.raw \ > out/t-${light}-${chn}-h0-${shutter}.pgm piketopnm -crop 502 0 498 1000 -extract ${chn} \ < data/t-${light}-${shutter}.raw \ > out/t-${light}-${chn}-h1-${shutter}.pgm done done done Fitting a linear model to the images as a function of shutter value: for light in ${lights[@]} ; do for chn in G0 G1 R0 B0 ; do for half in h0 h1 ; do pname="out/t-${light}-${chn}-${half}" tmp="/tmp/$$" echo "pname = '${pname}' tmp = '${tmp}'" pargs=() tfiles=() for shutter in ${shutters[@]} ; do iname="out/t-${light}-${chn}-${half}-${shutter}" tname="${tmp}-${light}-${chn}-${half}-${shutter}" pnm_to_fni -min 0 -max 1 < ${iname}.pgm > ${tname}.fni shval=`echo "${shutter}" | tr -d 's'` pargs=( "${pargs[@]}" -image ${shval} / 4095 "${tname}.fni" ) tfiles=( "${tfiles[@]}" "${tname}.fni" ) done echo "pargs = '${pargs[@]}'" # Fit linear model: fni_lin_fit \ "${pargs[@]}" \ -scale 65535 \ -gain ${pname}-g.fni \ -offset ${pname}-o.fni \ -origin ${pname}-s.fni \ -verbose rm -f ${tmp}-*.fni done done done Ploting histograms: for light in ${lights[@]} ; do for chn in G0 G1 R0 B0 ; do for half in h0 h1 ; do cname="out/t-${light}-${chn}-${half}" for ps in g.256 o.16 s.16 ; do param="${ps%.*}" step="${ps#*.}" pname="${cname}-${param}" fni_hist -range -100000 100000 -step ${step} \ < ${pname}.fni \ > ${pname}-hist.eps && \ gv ${pname}-hist.eps done done done done Displaying the parameters: for light in ${lights[@]} ; do for chn in G0 G1 R0 B0 ; do for half in h0 h1 ; do cname="out/t-${light}-${chn}-${half}" fni_to_pnm -min 0 < ${cname}-g.fni | convert PPM:- ${cname}-g.png fni_to_pnm -center 0 < ${cname}-o.fni | convert PPM:- ${cname}-o.png fni_to_pnm -center 0 < ${cname}-s.fni | convert PPM:- ${cname}-s.png display -title '%f' ${cname}-{o,g,s}.png done done done Comparing the gains with different lightings: fni_to_pnm -min 0 -max 65535 < out/t-a000d0-G0-h0-g.fni > out/t-a000d0-G0-h0-g.pgm fni_to_pnm -min 0 -max 65535 < out/t-a180d0-G0-h0-g.fni > out/t-a180d0-G0-h0-g.pgm pnmxarith -scale 0.5 -divide out/t-a000d0-G0-h0-g.pgm out/t-a180d0-G0-h0-g.pgm > out/t-a000d0-over-a180d0-G0-h0-g.pgm display -title '%f' out/t-a000d0-G0-h0-g.pgm out/t-a180d0-G0-h0-g.pgm out/t-a000d0-over-a180d0-G0-h0-g.pgm pnm_to_fni -min 0 -max 65535 < out/t-a000d0-over-a180d0-G0-h0-g.pgm > out/t-a000d0-over-a180d0-G0-h0-g.fni fni_hist -range -10000 100000 -step 16 < out/t-a000d0-over-a180d0-G0-h0-g.fni > out/t-a000d0-over-a180d0-G0-h0-g-hist.eps gv out/t-a000d0-over-a180d0-G0-h0-g-hist.eps JUNK Attempt to analyze the gain discontinuity at column 500 (actually 502) We extract columns 499 and 500 as a single ASCII PPM file with one pixel per row and a blank line after each scanline. More precisely we take columns 249 and 250 from Bayer channels G0 and G1: for exp in 0 1 2 3 4 ; do for chn in G0 R0 B0 G1 ; do iname="data/t_00${exp}" oname="out/t_00${exp}-${chn}-249-250" piketopnm -extract ${chn} < ${iname}.raw \ | pnmnoraw \ | pnmcut 0 251 500 2 \ > ${oname}.pgm display ${oname}.pgm plot-two-col-pgm.sh ${oname}.pgm display ${oname}-plot.png done done Comparing the gains of two images taken under identical conditions of lighting (only with paper shift): for disp in d0 d2 ; do convert out/t-a180${disp}-G0-h0-g.png -crop '64x64+80+120' out/t-a180${disp}-G0-h0-g.pgm done plot-compare-pgms.sh out/t-a180d0-G0-h0-g.pgm out/t-a180d2-G0-h0-g.pgm > out/t-a180d0-a180d2-G0-h0-g.png display out/t-a180d0-a180d2-G0-h0-g.png