Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Software binning explained


david_taurus83

Recommended Posts

Hoping someone can explain this in a bit more detail without my humble brain crashing. I've seen it mentioned a few times that the ASI1600 CMOS sensor doesn't bin in the same sense as a "traditional" CCD chip where the CCD gives the added increase of SNR. I've always assumed that when I select 2x2 with the ASI1600 that the capture software was "binning" the downloaded image. To my eye, the sub does look brighter and appears to have more detail. But I assume that the noise is also increased so all I've achieved is to make the image smaller with no real increase in SNR. I've seen @vlaiv mention on a few occasions that the subs could be processed as normal at full resolution and then could be resampled later in processing. Are there any steps on how to do this? Any comparison pictures out there? I've seen plenty of chatter about software binning but does anyone regularly use this approach?

 

Currently, my image scale is 2.33"pp at 336mm and 1.39"pp at 564mm with my 2 refractors so no need to bin there. But I've been thinking about a longer focal length for small targets, galaxies etc. Something along the lines of a 6" RC at 1370mm but with an image scale of 0.57"pp. My guiding would surely be tested at that plus it would be massively over sampling with my rubbish skies. Hence the question at hand.

Link to comment
Share on other sites

1 hour ago, david_taurus83 said:

Hoping someone can explain this in a bit more detail without my humble brain crashing. I've seen it mentioned a few times that the ASI1600 CMOS sensor doesn't bin in the same sense as a "traditional" CCD chip where the CCD gives the added increase of SNR. I've always assumed that when I select 2x2 with the ASI1600 that the capture software was "binning" the downloaded image. To my eye, the sub does look brighter and appears to have more detail. But I assume that the noise is also increased so all I've achieved is to make the image smaller with no real increase in SNR. I've seen @vlaiv mention on a few occasions that the subs could be processed as normal at full resolution and then could be resampled later in processing. Are there any steps on how to do this? Any comparison pictures out there? I've seen plenty of chatter about software binning but does anyone regularly use this approach?

 

Currently, my image scale is 2.33"pp at 336mm and 1.39"pp at 564mm with my 2 refractors so no need to bin there. But I've been thinking about a longer focal length for small targets, galaxies etc. Something along the lines of a 6" RC at 1370mm but with an image scale of 0.57"pp. My guiding would surely be tested at that plus it would be massively over sampling with my rubbish skies. Hence the question at hand.

Ok, here is sort of as simple as it can get explanation of binning, and related CMOS vs CCD thing.

- Binning increases SNR in the same way stacking does (or rather very similarly, there are small differences not important to this discussion). When you stack 4 images - you are adding / averaging pixel values between those images. Binning is adding / averaging 4 pixel values in 2x2 matrix - in principle same thing. So binning is always increasing SNR of recorded data predictably - bin 2x2 you increase SNR by factor of 2 (same as stacking 4 subs). Bin 3x3 - you increase SNR by 3 (same as stacking 9 subs, as you are adding/averaging 9 pixels)

- Difference between hardware binning (CCD) and software binning (CMOS) is what recorded data is being binned. With CMOS you are binning completely read out data, while with CCD you are binning electrons prior to them being read out. There is subtle difference between the two - CMOS binning is after each value had read noise added to it, while CCD binning is done prior to analog-digital conversion and read noise is added to binned value. Difference between the two is - hardware binned pixel (or group of 2x2 pixels) has regular level of read noise - same as single pixel. Software binned pixel has twice higher read noise than single pixel. In another words - if CCD camera has read noise of 5e, when you bin 2x2 and get sub with less pixels (and higher SNR) it will also have read noise of 5e. On the other hand if CMOS sensor has read noise of let's say 1.7e (like ASI1600), after you bin it - it will behave as camera with larger pixels but each pixel having 3.4e read noise. That is the only difference between software and hardware binning (if we bin in "regular" way, software binning can have certain advantage related to pixel blur, but that is "advanced" topic).

- as for resampling, binning is a sort of resampling, but it is not only way to resample image. There are couple of things that resampling or rather downsampling does to your data: it creates less pixels covering same FOV - hence it reduces sampling rate, it changes SNR of your data and has some effect on pixel blur and possibly introduces correlation between pixels (last two have small impact on sharpness of the image). Different resampling methods give different results in all of these except producing same sampling rate. Binning is predictable - it creates larger pixel so SNR increase is known, and it adds pixel blur. It does not add correlation between pixel values. Other forms of resampling can add less of pixel blur so image will be slightly sharper, but SNR increase is less (sometimes even more, at expense of noise statistics because of correlation) and there will be correlation between pixels (that has to do with noise statistics of the image).

I regularly bin my data in software when I record it with 8" RC (1624mm FL) and ASI1600. Native sampling rate is around 0.5"/px and that is of course way too much. Sometimes I bin it 2x2 and sometimes 3x3 - depending on conditions of the session.

Here is an example of binned image vs unbinned image that clearly shows improvement in SNR:

image.png.c3d90200fb592c72bd16db3cf1efcc99.png

This is single 60s uncalibrated sub of M51 taken with above gear. I created a copy of that sub, and with first copy I did software bin 2x2, while with other one I did "downsample" in particular way - one that really does nothing to the image except change sampling rate - so no correlation between pixels, no pixel blur and no SNR change (I simply took every other pixel in X and Y and formed image out of those - no addition, no interpolation, just x2 lower sampling rate to match the scale of binned image). Then I pasted part of second copy over first copy and did basic linear stretch to show result in such way that can be easily compared.

One simply cannot not notice improvement in SNR (it is x2 improvement in SNR). Btw, above image is 50% scaled down, but here is the same image at 1:1 zoom:

image.png.1e21a9403b24b45bca1deed8ba5a6ecd.png

(notice that scaling down for display, which also uses downsampling, improves SNR a bit, so scaled down version above does look smoother than this one at 1:1, but in order to really compare results - we need to measure resulting noise in different approaches to determine how each one behaves - I can do that for you as well if you want - make composite image of 4 different approaches - bin x2, above splitting of pixels, simple resample, and advanced resample technique and do some measurements of noise - as well as star FWHM so you can see the impact on resolution).

Edited by vlaiv
typo ...
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Thanks vlaiv. I kind of get the first bit. CMOS binning does increase signal but it also increases noise by the same amount. Youd still need the same number of subs to overcome the read noise. So no real benifit apart from smaller files.

 

In your example, the software binned image is on the left and the simple resample (50% down sample?) is on the right, yes? What process did you use to software bin? I resampled an image last night by 50% as the data wasnt good but I was mistaken by thinking this is what you refer to as software binning.

Link to comment
Share on other sites

1 hour ago, david_taurus83 said:

Thanks vlaiv. I kind of get the first bit. CMOS binning does increase signal but it also increases noise by the same amount. Youd still need the same number of subs to overcome the read noise. So no real benifit apart from smaller files.

No. Don't think in terms of increasing signal and increasing noise. Think in terms of ratio of the two. Depending on the type of stacking / binning you are using, signal can increase or stay the same.

If you are adding things - signal will increase. If you are averaging things - it will stay the same. Regardless of what method you choose, SNR improvement is the same.

Read noise is not only source of noise, and if you properly expose your subs - it should have smallest impact (or rather - your sub duration should be such that read noise is no longer dominant source of noise). Therefore binning improves SNR regardless if effective read noise is increased in case of software binning. In fact - you should not look at it that way, with software binning - read noise "remains the same", but hardware binning is slightly reducing read noise. Both however improve signal to noise ratio.

1 hour ago, david_taurus83 said:

In your example, the software binned image is on the left and the simple resample (50% down sample?) is on the right, yes? What process did you use to software bin? I resampled an image last night by 50% as the data wasnt good but I was mistaken by thinking this is what you refer to as software binning.

Depending what software are you using to process your data, software binning (true binning) can have different "name". For example if you use PixInsight - software binning is called "Integer Resample". You should use integer resample with average method for binning your data.

Here is another "synthetic" example:

image.png.f1917ba8f9d9908c820c98efd3ca2b9d.png

This montage is composed out of 4 panels - top right is original panel with gaussian noise with standard deviation of 1. Other panels are produced by:

1. binning 2x2 - average method

2. Simple bicubic interpolation

3. Cubic-O-MOMS interpolation

Here are results of measurement of noise in each sub:

image.png.8425b5473bb532b00fffd63fc4eb24a4.png

First is reference sub, and it has StdDev of 1 (noise with value 1).

Next one is binning 2x2 - it results in very predictable improvement of x2 (noise is less by a half or - 0.499....).

Simple bicubic interpolation reduces noise even further to 0.4, or by factor of about x2.5, but in doing so creates correlation between pixels and slightly blurs the image.

Cubic O-Moms is last, has the least SNR improvement by factor of x1.25, but should be the "sharpest" method.

In this example I did not examine impact on sharpness on the image - just on the noise. However, you can clearly see couple of important points:

1. Binning produces exact reduction in noise by factor of two (if signal remains the same - average method)

2. Quality resampling method like Cubic O-MOMS has less of SNR improvement (in this case factor of x1.25)

3. Every downsampling method does improve SNR to some extent, and some even more than binning - at expense of resolution (not seen in this example, but that is what happens).

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

2 hours ago, david_taurus83 said:

Thanks. I will have a look at IntegerResample. Would this be best applied to subs prior to stacking? I dont suppose it offers a batch method..

Yes, after calibration and before stacking. I don't use PI, so can't tell if there is option for batch, but I don't see why it would not work.

Link to comment
Share on other sites

On 13/10/2019 at 13:27, vlaiv said:

Here is an example of binned image vs unbinned image that clearly shows improvement in SNR:

Sorry vlaiv, but this is misleading. Software binning does not change the S/N per sq arcsec on the sky, so the two halves of your images should look identical. It looks like you threw away 3/4 of the data when downsampling the unbinned shot.

NigelM

Link to comment
Share on other sites

3 minutes ago, dph1nm said:

Sorry vlaiv, but this is misleading. Software binning does not change the S/N per sq arcsec on the sky, so the two halves of your images should look identical. It looks like you threw away 3/4 of the data when downsampling the unbinned shot.

NigelM

Not sure why you are saying it is misleading?

You are in fact correct than S/N per surface area is not changed, but point of binning is to trade "pixel surface area" for S/N improvement - one gets coarser sampling rate by doing this. I did point out that I rescaled unbinned shot to make creating composite easier and to make it easier for people to see the real improvement in S/N. I also made it clear how I did it - by in fact "throwing away" 3/4 of the data, but in doing so I did downsample without affecting "per pixel" SNR of original image, I did not introduce pixel-to-pixel correlation, nor did I affect sharpness of the image apart from any removal of high frequency signal due to using coarser sampling (which in fact does not happen in this image since image is oversampled as is).

 

Link to comment
Share on other sites

To be honest I don't see any difference in my images binnedx2 and unbinned except for the resolution if zoomed in.

If you use binning for the colour component of an image, it's not so important for the detail, and if you blur it a bit and then lay the unbinned Ha or Lum over the top, this gives you the detail, it works just fine.  I use it all the time because of lack of time in clear and dark skies.

Obviously of course you need software to re-size the binned data to match the unbinned data.

I do use a CCD camera but doubtless the principle is much the same. 

Carole

Edited by carastro
  • Like 1
Link to comment
Share on other sites

On 14/10/2019 at 22:40, david_taurus83 said:

Based on what vlaiv has explained above and what I've read elsewhere, the SNR on a CMOS is increased x 2 so I might just give "on camera" binning a go with my 102mm. I'll still have 2.78" pp resolution.

My understanding is that this is not optimal. There is limited benefit to binning cmos at capture time because there is no read noise gain. If you had excellent seeing but captured binned then you are effectively throwing away resolution (especially up at 2.8" pp). You also get more control of the binning by doing it post-capture.

 

(You do of course gain in data volume by software binning but hard disks are cheap)

  • Like 1
Link to comment
Share on other sites

50 minutes ago, jimjam11 said:

My understanding is that this is not optimal. There is limited benefit to binning cmos at capture time because there is no read noise gain. If you had excellent seeing but captured binned then you are effectively throwing away resolution (especially up at 2.8" pp). You also get more control of the binning by doing it post-capture.

 

(You do of course gain in data volume by software binning but hard disks are cheap)

Indeed, no benefit in doing it on chip, except for file size / download time.

Doing it in software leaves much more possibilities for data manipulation - like hot pixel exclusion, optimized binning based on SNR (examining master dark for statistics will tell you which pixels contain how much noise - there are more noisy and less noisy pixels and you can bin adaptively). You can also do "split" bin instead of regular (better option for preserving sharpness) and of course fractional binning.

Link to comment
Share on other sites

1 hour ago, jimjam11 said:

My understanding is that this is not optimal. There is limited benefit to binning cmos at capture time because there is no read noise gain. If you had excellent seeing but captured binned then you are effectively throwing away resolution (especially up at 2.8" pp). You also get more control of the binning by doing it post-capture.

 

(You do of course gain in data volume by software binning but hard disks are cheap)

I dont understand how an increase of x2 SNR is not beneficial?

Unless theres another practical method that Pixinsight doesn't possess, that's a hell of a lot of subs to manually open up and bin. I collected 1200 x 30s subs on a target this year!

Has anyone captured binned data and compared that to the same data, captured at the same time at full resolution but binned in software?

I appreciate the maths might not stack up but isn't the whole idea of the hobby about creating pleasing images to the eye?! What I mean is how does one image look compared to the other?

Link to comment
Share on other sites

2 minutes ago, david_taurus83 said:

I dont understand how an increase of x2 SNR is not beneficial?

Unless theres another practical method that Pixinsight doesn't possess, that's a hell of a lot of subs to manually open up and bin. I collected 1200 x 30s subs on a target this year!

Has anyone captured binned data and compared that to the same data, captured at the same time at full resolution but binned in software?

I appreciate the maths might not stack up but isn't the whole idea of the hobby about creating pleasing images to the eye?! What I mean is how does one image look compared to the other?

I don't think above refers to usefulness of on chip binning with CMOS in terms of SNR gain. It refers to the fact that doing it on chip provides only one benefit - smaller files.

There are several benefits when doing it in software - look at my post above.

Both on chip and in software will provide same SNR gain and will be equal if "standard" binning is used.

Link to comment
Share on other sites

There is an example here which can be easily modified to batch bin:

http://pixinsight.com.ar/en/info/articles/23/batch-processing.html

The only problem with this approach is if your image has WCS coordinates PI will raise an alert for every file that you need to dismiss!

Edit:

If you change the xisf file treatment you can get around this as well:

https://pixinsight.com/forum/index.php?topic=11616.0

Edited by jimjam11
Link to comment
Share on other sites

Just ran an experiment on some of my IC1396 data. For a stack of 59x300s subs I get:

No binning - SNR: 3.59, FWHM: 2.706px = 3.14"

Bin2 before integration - SNR: 6.09, FWHM: 1.599 = 3.69"

Bin2 after integration - SNR: 6.18, FWHM: 1.598 = 3.69"

I got SNR by getting the AvgDev for each image as S, and the noise value from the NoiseEvaluation script as per this link

Both of the binned images look cleaner but they are much less sharp 

 

bin2.fit NoBin.fit NoBin_int_Bin2.fit

Link to comment
Share on other sites

6 minutes ago, jimjam11 said:

Just ran an experiment on some of my IC1396 data. For a stack of 59x300s subs I get:

No binning - SNR: 3.59, FWHM: 2.706px = 3.14"

Bin2 before integration - SNR: 6.09, FWHM: 1.599 = 3.69"

Bin2 after integration - SNR: 6.18, FWHM: 1.598 = 3.69"

I got SNR by getting the AvgDev for each image as S, and the noise value from the NoiseEvaluation script as per this link

Both of the binned images look cleaner but they are much less sharp 

 

bin2.fit 15.67 MB · 0 downloads NoBin.fit 62.56 MB · 0 downloads NoBin_int_Bin2.fit 15.67 MB · 0 downloads

What was original sampling rate?

Btw, can you try "split" bin to see if you retain some of the sharpness and get the same SNR improvement?

I'm not sure that there is option in PI to do split bin, but I've seen a script somewhere that does it (it is not actually designed for that, but for splitting bayer matrix into 4 color subs - R, 2xG and B, if you run it on mono sub, you will end up with 4 subs of x2 coarser sampling rate but same pixel size - you increase number of stacked subs by factor of x4 and that leads to overall improvement in SNR by factor of x2 - same as binning).

Link to comment
Share on other sites

2 minutes ago, vlaiv said:

What was original sampling rate?

Btw, can you try "split" bin to see if you retain some of the sharpness and get the same SNR improvement?

I'm not sure that there is option in PI to do split bin, but I've seen a script somewhere that does it (it is not actually designed for that, but for splitting bayer matrix into 4 color subs - R, 2xG and B, if you run it on mono sub, you will end up with 4 subs of x2 coarser sampling rate but same pixel size - you increase number of stacked subs by factor of x4 and that leads to overall improvement in SNR by factor of x2 - same as binning).

Original sampling rate was 1.16" pp

More research required to see if I can split bin! Is there another tool which does this easily?

Link to comment
Share on other sites

49 minutes ago, jimjam11 said:

Original sampling rate was 1.16" pp

More research required to see if I can split bin! Is there another tool which does this easily?

I can send you source of ImageJ plugin that will do it if you want? Not sure if you are familiar with that software package - it is free, written in Java so works on various operating systems ....

At 1.16"/px, bin x2 will produce resolution of 2.32"/px, and that is just a bit lower sampling rate than is needed for 3.14" FWHM stars, which should be around ~1.95"/px - so not much loss but there will be a bit of increase in FWHM due to this. Rest is down to pixel blur.

What resampling method are you using when registering your subs? I think there is an option in PI to select Lanczos resampling (maybe it is even default) - you should use that one for sub registration after binning.

Link to comment
Share on other sites

11 minutes ago, vlaiv said:

I can send you source of ImageJ plugin that will do it if you want? Not sure if you are familiar with that software package - it is free, written in Java so works on various operating systems ....

At 1.16"/px, bin x2 will produce resolution of 2.32"/px, and that is just a bit lower sampling rate than is needed for 3.14" FWHM stars, which should be around ~1.95"/px - so not much loss but there will be a bit of increase in FWHM due to this. Rest is down to pixel blur.

What resampling method are you using when registering your subs? I think there is an option in PI to select Lanczos resampling (maybe it is even default) - you should use that one for sub registration after binning.

Never used it before. Would it be simple to run over a set of files and produce the sub-divided subs?

Using auto, never even looked that far down the star alignment process before!

Specifying Lanczos-3 I get a FWHM in the integrated stack of 1.594px = 3.68"

Link to comment
Share on other sites

2 minutes ago, jimjam11 said:

Never used it before. Would it be simple to run over a set of files and produce the sub-divided subs?

Using auto, never even looked that far down the star alignment process before!

Specifying Lanczos-3 I get a FWHM in the integrated stack of 1.594px = 3.68"

It should be fairly easy to do. Just have your subs calibrated and saved in single folder in 32bit fits format.

Download ImageJ and put it somewhere on your file system (it does not install, you can run it from that folder). I can either provide you with source code, or compiled plugin. Later is simpler as you need to just copy it to plugins folder inside ImageJ folder (it is already there).

You need to restart ImageJ if it were open for it to recognize new plugin.

After that it is only matter of:

1. File / import / image sequence

here you select first image in your folder, it should pick up on all others (there are options to "filter" what subs you want to load). This will open "stack" in ImageJ

2. Next you open Plugin / Sift bin V2 and select following settings:

image.png.7844d9a6fdc9d271cd5a114c517f755e.png

It should create another stack of images that contains x4 as many subs and has twice smaller height and width.

3. Save as / image sequence will let you save those subs

choose fits format, give it a name, and number of digits (they will be for example labeled name001, name002 ....).

That is it.

Plugin is attached : Sift_Bin_V2.class

 

Link to comment
Share on other sites

Thanks,

That was relatively easy to do and produced the following numbers:

No binning - SNR: 3.59, FWHM: 2.706px = 3.14"

Bin2 before integration - SNR: 6.09, FWHM: 1.599 = 3.69"

Bin2 after integration - SNR: 6.18, FWHM: 1.598 = 3.69"

SiftBin - SNR: 6.27, FWHM: 1.572 = 3.63"

It definitely works, it gave tighter stars and a better SNR! 1682355486_2019-10-16(3).thumb.png.98da92fba4921b7a6950f40c3de8b9fb.png

 

Was this the tool you used to downsize your example image higher up without any resampling?

Link to comment
Share on other sites

1 hour ago, jimjam11 said:

No binning - SNR: 3.59, FWHM: 2.706px = 3.14"

Bin2 before integration - SNR: 6.09, FWHM: 1.599 = 3.69"

Bin2 after integration - SNR: 6.18, FWHM: 1.598 = 3.69"

SiftBin - SNR: 6.27, FWHM: 1.572 = 3.63"

I was expecting something along these numbers.

This splitting approach works the best for two reasons:

1. Pixel blur. It makes small but measurable difference. Larger the pixel surface - larger pixel blur. With regular binning method (both hardware and software) we are in fact increasing pixel size. This adds small amount of blur to resulting data. With splitting of subs we are leaving pixels as they were, and result will have slightly smaller FWHM in comparison to regular bin method because of that.

2. There is also small SNR boost over regular binning. This has more to do with the way data is stacked than binning process itself. Resampling needed to align frames (although resolution does not change, we need sub pixel shifts and sometimes a bit of rotation to align images - so we must resample / interpolate image) has effect on both noise and signal. Depending on type of resampling used it can have significant effect. Signal can be additionally blurred while noise cut down as result of that.

This is why I recommend using Lanczos resampling - it offers best results for properly sampled data. It will cut off noise frequencies above sampling frequency, and it will not add almost any blur to the image if image is sampled properly. Coupled with the fact that we did not change pixel values with splitting, and it has original noise distribution (unlike with regular binning where noise is reduced and data a bit blurred due to pixel blur) - enables actual resampling to do a bit of noise reduction by "cleanly" cutting higher noise frequencies.

1 hour ago, jimjam11 said:

Was this the tool you used to downsize your example image higher up without any resampling?

Yes, that is precisely what I used.

If you work with OSC cameras as well, you can use this tool to separate colors, but you need to know your bayer matrix order. After you split your subs into channels - you can continue using RGB type of processing approach - you will have set of red subs, set of green subs (twice as many - better SNR which is good as luminance depends mostly on green) and set of blue subs.

  • Like 1
Link to comment
Share on other sites

Whilst we went on a bit of a detour I think we have shown a couple of things:

1. The SNR improvement is measurable and visible.

2. The benefits of binning post acquisition massively outweigh the cons because it gives you choices; I see this in the same way I see RAW vs jpg with a dslr...

Link to comment
Share on other sites

I have taken some images the other night to compare no binning, binning on camera and binning in Pixinsight. The results are just as you've described @vlaiv  I took 40 x 90s L subs of the Crescent Nebula at 59 gain and 60 offset. I took 2 sets, the first at 1x1 and the next at 2x2 on camera.

 

The on camera binning makes a right pig's ear of things! The stars are horrible and blocky! Wont be doing that again! I also used IntegerResample to down sample the 1x1 stack and I also down sampled the 1x1 subs and then stacked those. Thanks @jimjam11  for that tip about the image container! Made it much easier to batch down sample.

There is clearly an improvement on star size and shape. Running SubframeSelector on the 4 images also shows this with an improvemnt in FWHM and eccentricity. How do you calculate your signal to noise ratios?

binning.PNG

Edited by david_taurus83
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.