Author Topic: Software binning in PI  (Read 10208 times)

Offline FunTomas

  • PixInsight Addict
  • ***
  • Posts: 135
    • Astrofoto.sk
Software binning in PI
« on: 2011 June 27 22:59:08 »
Is it possible to perform software binning in PixInsight? I think, that Geometry / Integer resample is not usable for this. Here are only Average, Median, Maximum or Minimum as operation, but not Add (Sum). Thank for any response.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Software binning in PI
« Reply #1 on: 2011 June 27 23:37:06 »
Hi,

Yes, Geometry > IntegerResample is what you are looking for. The default parameters (downsample/average) perform a 2x2 binning.

Quote
Here are only Average, Median, Maximum or Minimum as operation, but not Add (Sum).

Average and add (sum) are equivalent in terms of SNR increment. The advantage of average is that you can't get out-of-range pixel values.

If you really want to perform a 'pure' 2x2 binning by summing 4-pixel blocks, this is very easy with PixelMath:

- In the 'Symbols' field type the following:

Code: [Select]
x2, y2
This allows PixelMath to use x2 and y2 as variable names instead of as image identifiers.

- Click the Edit button to the right of the RGB/K expression field and write this PixelMath expression:

Code: [Select]
x2 = 2*x();
y2 = 2*y();
pixel( $T, x2, y2 ) + pixel( $T, x2+1, y2 ) + pixel( $T, x2, y2+1 ) + pixel( $T, x2+1, y2+1 )

The expression above computes the sum of each contiguous block of 2x2 pixels in the source image.

- Uncheck the 'Rescale result' PixelMath option.

- Open the Destination section and select the following:

* Create new image: checked
* Image id: the identifier you want; for example: binned2x2
* Image width and Image height: the dimensions of your original image halved. If your image is 4096x4096, you should enter 2048 and 2048 here.
* Color space: same as target
* Sample format: 32-bit floating point (recommended)

Execute this PixelMath instance on your unbinned image and you'll get a binned result as a new image window. As I've said above, the result is the same as if you used IntegerResample in average downsampling mode in SNR terms, but the range of values is different. With a pure binning procedure, if a 2x2 block in your original image sums up more than one, the resulting binned pixel will be saturated.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline FunTomas

  • PixInsight Addict
  • ***
  • Posts: 135
    • Astrofoto.sk
Re: Software binning in PI
« Reply #2 on: 2011 June 28 00:35:00 »
Wow. Thank you very much Juan. PixInsight does anything. We only need to know, how to do it.

Offline darrynl

  • Newcomer
  • Posts: 6
Re: Software binning in PI
« Reply #3 on: 2016 May 04 06:56:09 »
This was a very useful script to rescue some old images -- thanks.

Should I do software binning before or after image integration (stacking)?

thanks

Darryn

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: Software binning in PI
« Reply #4 on: 2017 October 14 09:47:46 »
I want to use this pixelmath that Juan posted in batch mode so that I can apply it to lots of images in one operation.

It does not work properly using ImageContainer as it creates a file saved to disk which is the wrong size, i.e. the size is not reduced. But it also creates a file on the desktop using default names image01, image02 etc. These are the correct files, but you have to do a save-as for each one.

Is this possible ?

Thanks,

Mike

Offline sharkmelley

  • PTeam Member
  • PixInsight Addict
  • ***
  • Posts: 241
    • Mark Shelley Astrophotography
Re: Software binning in PI
« Reply #5 on: 2017 October 14 11:17:19 »
Maybe it works differently if you uncheck the PixelMath "Create new image" option?

Mark
Takahashi Epsilon 180ED
H-alpha modified Sony A7S
http://www.markshelley.co.uk/Astronomy/

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: Software binning in PI
« Reply #6 on: 2017 October 14 15:25:45 »
Hi Mark,

Unfortunately it needs the "Create new image" to work or it does not resize the image.

Mike