Page 1 of 1

Pixel Binning

Posted: Thu Jan 14, 2010 6:57 pm
by Jack Harrison
I am trying to get to grips with Pixel Binning. If you don’t already know, this is a technique which uses adjacent pixels and averages. It can have many advantages such as increased dynamic range. But there are certainly downsides.

To give an example: if I take a picture at 4000 * 3000 and then use each adjacent pixel to produce a “super pixel”, I will have in effect finished up with an image a mere 1000 * 750 (I think my logic is correct here). That image might indeed have a much smoother appearance but lacks the resolution of the original. So it’s a trade off. Nevertheless, pixel binning is extensively used in astro-photography (including NASA) so obviously has benefits.

I’m not quite sure how to do it with ordinary photos, but am getting some ideas. If, for example, I simply resize 4000 * 3000 down to 1000 * 750, the results can be horrible with “moiré effects” (look it up.) But if prior to resize, I give a small Gaussian blur and then resize, the results can be a lot better. Photo Shop seems to do this semi-automatically (but not to my total satisfaction).

My point is this. Googling for pixel binning gives lots of hits - discussing advantages and disadvantages - but I have been unable to find a method of actually doing it.

Any suggestions?

Jack

Re: Pixel Binning

Posted: Thu Jan 14, 2010 8:08 pm
by JKT
Have you tried the different interpolation algorithms in PhotoShop? Bilinear might be the most appropriate here.

I've always wanted my camera to have double resolution compared to my screen. That is kind of binning too, though it just partially removes inaccuracies caused by the Bayer interpolation.

I don't quite know how it increases dynamic range except by eliminating some noise in the lower end.

Re: Pixel Binning

Posted: Fri Jan 15, 2010 8:04 am
by Jack Harrison
JKT:
Have you tried the different interpolation algorithms in PhotoShop? Bilinear might be the most appropriate here.
Yes I’ve tried that but I don’t know what is actually happening. See comment later.

The idea as I (incompletely) understand is that, for example, a block of 2x2 pixels is combined to be one “super pixel”. The average of all the colours of each pixel is now the colour of the super pixel; small artifacts and noise are less noticeable. I have a camera with sensor of size 7.6x5.7 mms. On that sensor are 12 million pixels, rather a large number for such a small sensor, so noise, diffraction, etc, are a limitation. So there is the concept of number of pixels per unit area of sensor. The smaller that number, the better. This of course is why DSLRs with much larger sensors for a similar number of pixels are capable of better quality images but with some downsides as well. (I don’t want to debate the pros and cons of DSLRs here)

So I am trying to find out how to carry out that pixel binning. The example above (2x2 – a similar term is used by NASA in connection with improving images) would of course reduce my camera to give only 2000x1500 super pixels. However being on the same size sensor, there would be fewer pixels per square centimetre. Most of my pictures are viewed on the computer screen and only rarely printed so 2000*1500 would be more than adequate and still leave scope for cropping.

Perhaps using Photo Shop bicubic sharper is achieving precisely what I want. Alternatively I can get a similar effect by applying Gaussian Blue (typically 0.7 pixels), then resizing followed by sharpening. Are these techniques in effect pixel binning?

Jack

Re: Pixel Binning

Posted: Fri Jan 15, 2010 8:28 am
by JKT
I think that any size reduction by an integer factor is pixel binning. The problem is that the usual resizing methods use higher order interpolation and/or sharpening, which can lead to unnecessary artifacts. I'm not sure where the Moire comes from though - is it a leftover from the Bayer interpolation, a result of the artifacts or just natural part of a sharp picture. :)

The dynamic range improvent is an interesting concept here. If your pixels would not have ANY noise, you could not improve DR, but you could increase the pixel depth by adding immediate levels. On second thought that DOES increase the dynamic range as zero doesn't count - only the first step above zero does. So by pinning four pixels, you could say that your new minimum measured light is 1/4 of the original. (I hope I'm not too far off as this is written based on my feeling - not knowledge)

Re: Pixel Binning

Posted: Fri Jan 15, 2010 9:26 am
by Jack Harrison
Just found this on a NASA website:
Several data compression methods can be employed to optimize data return. The first compression method uses pixel binning where adjacent pixels in an image are summed equally in the cross-scan and down-scan pixel dimensions (permitted values: unbinned, 2, 3, 4, 8, 16). Binning reduces data volume and increases the pixel SNR, a useful option in low illumination viewing conditions.
Link:
http://starbrite.jpl.nasa.gov/pds/viewI ... OST_ID=MRO

There is also this but I can't begin to understand:
http://heasarc.nasa.gov/docs/software/f ... ode18.html

So while these refer to the advantages of pixel binning, I can't find out how they do it.

Jack

Re: Pixel Binning

Posted: Fri Jan 15, 2010 11:09 am
by JKT
Doing the actual binning is very simple. The problem is reading input from some image file and writing output to another. Those could be simplified by doing it inside image editing program, but they may not allow anything that simple. "Average" would be the interpolation method that would give the wanted results. That way you wouldn't get the increased dynamic range, but you would get noise reduction.

If you have four pixels with RGB values (10, 45, 240), (13, 46, 235), (12, 42, 241) and (9, 44, 239), the resulting binned pixel is (11, 44, 239) [or actually (11, 44.25, 238.75), but decimals are not available without increasing bit depth]. You simply add the R, G and B values and divide by the number of original pixels.

I think the most simple way to do the binning (4 pixels to 1) is this: "CONVERT original.tif -scale 50% final.tif" (or "CONVERT original.tif -filter box -resize 50% final.tif"). Naturally you need to install ImageMagick first. :D

Re: Pixel Binning

Posted: Fri Jan 15, 2010 11:35 am
by Jack Harrison
That sounds very interesting. I’ll give it a try this afternoon but have to go out shortly.

RGB outside approx 210,210,210, ie miserable fog.

Jack

Re: Pixel Binning

Posted: Fri Jan 15, 2010 2:41 pm
by Jack Harrison
Naturally you need to install ImageMagick first. :D
Yes! The smiley is clearly highly significant.

I tried to download and came across this term: command-line interface utilities. I am now totally lost. All I want is some simple software that will bin 4 pixels into 1 but simple is not apparently an option.....

Jack (retired hurt)

Re: Pixel Binning

Posted: Fri Jan 15, 2010 6:58 pm
by JKT
Oh, it is quite simple ... to do just about anything after you figure out the command to do it. :lol: I use the program quite a lot for combining pictures and the distribution maps on my pages are done with it as well. It is a good idea to write down the command you have succesfully used and what they do, though. That will help in the future. However, I gave you the required command for what you wanted. You just need to modify the size and filenames. The values 50% and 25% will work for sure. I'm not sure whether 33.3333% or 12.5% would work, but the latter is easy to do by using first 50% and then 25%. Just use a lossless image format as the intermediate file.

I don't know how well you know computers, so I'll try make the usage simple.
1. First you install ImageMagic. If the installer asks about appending the the imagemagick directory to path, let it do it. Otherwise it has to be done manually, which is somewhat difficult to explain.
2. Create empty text file named "GoDos.txt". (the actual name doesn't matter) and edit the contents to include one line of text: "START CMD". After saving that rename the file to "GoDos.bat". The system complains about changing the file type, but you can ignore that.
3. Copy that file to the same directory where you have the picture to Bin.
4. Double click on the file and you will get a DOS window.
5. Write the command I gave in the earlier post in the window and substitute the proper filenames and -types.

The step 2 is much easier if you have not hidden the extensions for the known file types, which Windows tends to do by default...

Re: Pixel Binning

Posted: Sat Jan 16, 2010 7:17 pm
by Jack Harrison
I’m sorry but my computer skills are not up to this. I have tried over the past 24 hours, but things like “Double click on the file and you will get a DOS window” are beyond my understanding. Sorry but I have to give it a miss. Thanks though for trying so hard to make it simple.

For the time being, I’ll stick with my Gaussian Blur + resize/sharpen. When someone comes up with a simple idiot-friendly program to do pixel binning, then I’ll think again. But in the meantime, I have to admit defeat.

I do have to wonder if pixel binning really is worthwhile for amateurs. Yet professional bodies seem to use it so it must have some value.

Jack

Re: Pixel Binning

Posted: Sat Jan 16, 2010 8:43 pm
by JKT
jackharr wrote:I do have to wonder if pixel binning really is worthwhile for amateurs. Yet professional bodies seem to use it so it must have some value.
I think it has value, but a very special one: It can be used to improve dynamic range in extreme situations like in astrophotography, where the difference between black and not quite black can be very, very small. That is almost never critical in normal photography.

Re: Pixel Binning

Posted: Tue Jan 19, 2010 11:01 am
by LCPete
Hi Its a bit over my head but I dont see how downsizing the image after it leaves the camera can improve dynamic range
What can help is that some cameras have an sRaw feature that using a smaller megapixal size on the sensor produces better but smaller files
Or getting the Canon 5D mk2 superb dynamic range but thats out of my price range
Pete