Author Topic: Normalize the sky background value on a sequence of images...  (Read 2944 times)

Offline mhebert

  • Newcomer
  • Posts: 9
Challenge for PI pros:

I would like to save a sequence of images after normalizing the sky background value for each of these images to a fixed value.
Moreover, I would like to save these images to a specific STF that I choose myself. At first, the images could be 16 bits FITS, but they can be saved in PNG format, with the choosen STF.
The goal is to get a sequence of PNG or JPEG files the most identical possible in order to make an animation.

I repeat that the most important thing is to normalize the sky background value of all (already calibrated) images, like we can do with the "noffset2" command in Iris.
Even if you have a solution for just this point, i will be happy to know how!

I suspect that it is necessary to use PixelMath and the image container, but I am not very familiar with Pixelmath, especially if it must act on a series of images.

Thank you !

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
blink will probably do what you want.

if you load all your images into blink, and then press the button that computes a per-image STF, the brightness of each image will be very similar. i believe, but i'm not sure, that blink takes the settings for the STF processs when computing an STF, you should be able to modify the default STF parameters if the stretch is not to your liking.

once that's done, you tell blink to create a movie. by default it's going to output PNG files but i think you can actually change that by specifying a different suffix - again, not sure because i've always just used PNG.

even if you don't have ffmpeg installed, blink will output the individual frames. but since you want to make a movie you can install ffmpeg and point Blink to the location of the binary and it should then make the movie. however the default parameters don't have high enough quality/bitrate for my taste so i just end up re-doing it anyway in the shell.

rob

Offline mhebert

  • Newcomer
  • Posts: 9
Thank your for your answer Pfile,

But your solution is exactly what i am doing actually, it gives rather good results. Thst's for now the best way to do.

But just for the exercise, i would like to specify myself a specific value for the sky background. The blink process seems to normalize the ENTIRE image, rather than the background itself. It sometimes create subtle variations in the sky background in case of comet animations.
In fact, the image integration process do what i want to do (normalisation) but unhappily, this action occurs only in memory, we can't output these intermediate, normalised images to disk!
This is why i would like to do it with some sort of batch action.
...Unless the PixInsight designers offer a case in the ImageIntegration process allowing us to output each normalised images to disk... ;-)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Quote
i would like to specify myself a specific value for the sky background.

The following PixelMath expression will do just what you want:

$T - median( $T ) + 0.125

where 0.125 is an example background value that you want to force (this value can be appropriate for a nonlinear image, but linear data will normally need a much lower one). This equation assumes that the median provides a robust estimate of the average sky background, which is true for most deep-sky images, where the sky dominates the distribution of pixel values.

If you have an image whose background you want to replicate, you can use:

$T - median( $T ) + median( ReferenceImage )

where 'ReferenceImage' is the identifier of the view in question (replace as appropriate).

Just for the record, a full scale + zero offset normalization would be, using MAD as scale estimator:

($T - median( $T ))*MAD( ReferenceImage )/MAD( $T ) + median( ReferenceImage )

You can automate PixelMath very easily with ImageContainer. Let me know if this helps.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mhebert

  • Newcomer
  • Posts: 9
Thank you for answering Juan,

What a simple and elegant way to do! I now catch the idea.
I didn't even heard of the "$T" utility in PixelMath, but with your example, i now see all the possibility it offers!

So i did some experiments with your examples and my linear images sequence.

It seems to produce consistent results when i proceed manually with each image of my sequence (loading an image, apply the "$T - median( $T ) + median( ReferenceImage )" to it, and the median of the resulting image is very near to reference, if not the same.

But when i try to apply this pixelmath formula in batch mode using ImageContainer, strange results occurs:
The median of successive images produced are slowly decreasing from image to image...

Any idea why it operates correctly if i do it manually, but incorrectly if i used PixelMath?

Offline mhebert

  • Newcomer
  • Posts: 9
Ok, i found my bug with PixelMath: i have to activate "replace target image" instead of "create a new image".
After that, all files go to disk with identical background.
Thanks!