I'm preparing a little blurb on binning as a way of reducing high-ISO
noise. I was going through some of the math, and came up with a
surprise, which may or may not mean anything in the real world...
Step 1) Start with an 8-bit-per-channel tiff file.
Step 2) This step deliberately left blank<g>.
Step 3) Bin the image using 2x2 grids. I.e. average 4 adjacent pixels
to create a pixel in the output image.
In base_2 "decimal point" format, the averaged value for each pixel
looks like binary xxxxxxxx.xx where "x" is either 0 or 1. This is due
to the fact that averaging amongst 4 pixels means dividing by 4. Since
we're dealing with an 8-bit tiff for output, the final result is
xxxxxxxx, which throws away some of the information.
Now let's go back, and insert a command at step 2. Let's "convert"
the image to a 16-bit-per-channel tiff. Instead of using 100% of 8-bit
colourspace, we're using 1/256th of 16-bit colourspace. The initial
values are all in the form binary xxxxxxxx00000000. The final result,
after step 3, will now be binary xxxxxxxxxx000000. In other words,
we've traded off image size for additional colours. I don't have a
video card or monitor or driver than can show more than 8 bits per
channel. I don't know the answer to the following questions...
1) Does it produce a noticeable difference, assuming you have the
necessary hardware and software to display more than 8 bits per channel?
2) If the answer to 1) is "yes", is the result an improvement over 8
bit colour?
My binning script follows. I call it "binn". It's invoked like so...
binn source_file output_file bin_factor
Since I'm running linux, I cobbled together a fancy script to
automatically calculate the new geometry rather than have the user
calculate it. E.g. it figures out that a 2048x1536 image binned 3x3
will result in a 682x512 output file.
#!/bin/bash
calcgeometry() {
x=`echo ${3} | sed "s/x.*$//"`
y=`echo ${3} | sed "s/^.*x//"`
newx=$((${x} / ${bin_size}))
checkx=$((${newx} * ${bin_size}))
if [[ ${checkx} -ne ${x} ]]; then
crop_flag="YES"
fi
newy=$((${y} / ${bin_size}))
checky=$((${newy} * ${bin_size}))
if [[ ${checky} -ne ${y} ]]; then
crop_flag="YES"
fi
newgeometry="${newx}x${newy}"
}
source_file=${1}
output_file=${2}
bin_size=${3}
crop_flag="NO"
calcgeometry `identify ${1}`
if [[ ${crop_flag} = "YES" ]]; then
cropgeometry="${checkx}x${checky}+0+0"
convert -depth 8 ${1} -crop ${cropgeometry} dummy.tif
source_file="dummy.tif"
fi
convert -depth 8 ${source_file} -filter box -resize ${newgeometry}
${output_file}
if [[ -a dummy.tif ]]; then
rm dummy.tif
fi
--
Walter Dnes <[EMAIL PROTECTED]> In linux /sbin/init is Job #1
My musings on technology and security at http://tech_sec.blog.ca
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users