New Feature : Background Subtraction

Discussions, Bug Reports and Issues related to Beta versions of SharpCap
User avatar
Tiago Ferreira
Posts: 143
Joined: Sun Mar 21, 2021 10:50 pm

Re: New Feature : Background Subtraction

#11

Post by Tiago Ferreira »

admin wrote: Tue Apr 13, 2021 5:25 pm Hi,

could you share a couple of individual frame images (saved without dark/flat) and any dark/flat frames you were using and I will test to see if I can work out what is going wrong.

thanks,

Robin
I forgot to save frames, i've only saved snapshot. Will try again.
Meanwhile here is what happened to the image and then i adjust histogram and start moving again like crazy.
I've tried again and the same.
Attachments
lstest Stack_27frames_108s_WithDisplayStretch.png
lstest Stack_27frames_108s_WithDisplayStretch.png (491.63 KiB) Viewed 2247 times
lstest Stack_19frames_76s_WithDisplayStretch.png
lstest Stack_19frames_76s_WithDisplayStretch.png (530.93 KiB) Viewed 2247 times
lstest Stack_14frames_56s_WithDisplayStretch.png
lstest Stack_14frames_56s_WithDisplayStretch.png (507.69 KiB) Viewed 2247 times
Youtube channel: https://youtube.com/@DobsonianPower

12" f/5 Dobsonian GSO
8" f/6 Dobsonian GSO
6" f/5 Dobsonian Go-To Virtuoso Gti
Dwarf II Smart Telescope
Geoptik Eartha Eq Platform
ZWO ASI224MC + ZWO ASI294MC
User avatar
admin
Site Admin
Posts: 13125
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: New Feature : Background Subtraction

#12

Post by admin »

Hi,

tricky to work anything out with the images that have already been through the processing sadly. I tried taking the first image (with the grey background) which I presume does not have background subtraction and loaded it into SharpCap and turned on the subtraction and the result came out OK with no pink colour.

Oddly if I take the pink image and use background subtraction on it, it gets rid of almost all the pink colour (because that's part of a fixed background).

I'll have another look when you get a chance to save some unprocessed frames.

cheers,

Robin
User avatar
Tiago Ferreira
Posts: 143
Joined: Sun Mar 21, 2021 10:50 pm

Re: New Feature : Background Subtraction

#13

Post by Tiago Ferreira »

i will do it again saving frames.
yes the 3rd picture is without subtraction.
Youtube channel: https://youtube.com/@DobsonianPower

12" f/5 Dobsonian GSO
8" f/6 Dobsonian GSO
6" f/5 Dobsonian Go-To Virtuoso Gti
Dwarf II Smart Telescope
Geoptik Eartha Eq Platform
ZWO ASI224MC + ZWO ASI294MC
User avatar
Tiago Ferreira
Posts: 143
Joined: Sun Mar 21, 2021 10:50 pm

Re: New Feature : Background Subtraction

#14

Post by Tiago Ferreira »

admin wrote: Sun Apr 18, 2021 5:01 pm Hi,

tricky to work anything out with the images that have already been through the processing sadly. I tried taking the first image (with the grey background) which I presume does not have background subtraction and loaded it into SharpCap and turned on the subtraction and the result came out OK with no pink colour.

Oddly if I take the pink image and use background subtraction on it, it gets rid of almost all the pink colour (because that's part of a fixed background).

I'll have another look when you get a chance to save some unprocessed frames.

cheers,

Robin
Well Robin i think i found the problem. Here is my report:
Tonight i was going to save the frames as planned so i started live stack and without darks to get darks out of the equation.
The image start as usual and i use the auto stretch as usual. Everything ok.
Then i change the background sub. simple offset to on. (the issue previous nights was equal in every situation)
Then the same behavior, the histogram curves start moving to the right and the image more and more pinkish, as uploaded photos.
This time i had the save all to catch the frames.
I test, autostretch again and histogram didn't stabilize, return to pink and moved.
Then i played manually with histogram adjustment and same thing, after that the histogram moved again to the pinkish style, gradually.
So i looked to the files and open and didn't see nothing special in any frame so i was going to record a video to see if i could explain better.
But then returning to sharpcap i cancelled the stack and returned to regular display view through sequencer, which clean it all, and then i returned to the live stack to record the video with my smartphone but this time the background feature was still ON and i leave it this way. I used the sequencer to enter live stack which don't change that background feature and the stack was working ok with no crazy moves. I've tried the autostretch and worked and stabilized. The colors AS also ok. Wait a bit and no problems at all. It was working. So i can't use those features on the go, i have to reset it all in order for them to work. I think that was the issue.
Youtube channel: https://youtube.com/@DobsonianPower

12" f/5 Dobsonian GSO
8" f/6 Dobsonian GSO
6" f/5 Dobsonian Go-To Virtuoso Gti
Dwarf II Smart Telescope
Geoptik Eartha Eq Platform
ZWO ASI224MC + ZWO ASI294MC
User avatar
admin
Site Admin
Posts: 13125
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: New Feature : Background Subtraction

#15

Post by admin »

Hi,

so your first stack which had the problem was a mix of background subtracted and not background subtracted. I can see why that would cause a problem, since once you have changed over each new frame will change the mix ratio, meaning that the histogram peaks will shift in the live stack and making it really hard to adjust.

glad you worked it out! In the documentation I will make sure to mention not to mix different choices for this control in a single live stack. The same applies for mixing frames with/without darks or with/without flats - avoid it if at all possible!

cheers,

Robin
User avatar
Tiago Ferreira
Posts: 143
Joined: Sun Mar 21, 2021 10:50 pm

Re: New Feature : Background Subtraction

#16

Post by Tiago Ferreira »

admin wrote: Mon Apr 19, 2021 6:38 pm Hi,

so your first stack which had the problem was a mix of background subtracted and not background subtracted. I can see why that would cause a problem, since once you have changed over each new frame will change the mix ratio, meaning that the histogram peaks will shift in the live stack and making it really hard to adjust.

glad you worked it out! In the documentation I will make sure to mention not to mix different choices for this control in a single live stack. The same applies for mixing frames with/without darks or with/without flats - avoid it if at all possible!

cheers,

Robin
The darks i always reset. But as i have it all at the sequencer i don't even think about it. In this case my laziness from using the sequencer made the mistake to forget that possibility. Here is another useful secondary feature for the sequencer, to set those values to on or off when starting a live stack sequence.
Youtube channel: https://youtube.com/@DobsonianPower

12" f/5 Dobsonian GSO
8" f/6 Dobsonian GSO
6" f/5 Dobsonian Go-To Virtuoso Gti
Dwarf II Smart Telescope
Geoptik Eartha Eq Platform
ZWO ASI224MC + ZWO ASI294MC
User avatar
Djibi
Posts: 6
Joined: Wed May 20, 2020 10:51 am

Re: New Feature : Background Subtraction

#17

Post by Djibi »

First test of Background Substraction (from Folder Monitaor Camera)

Hello Robin,
I just installed the Beta version and begun to play with Background substraction with the folder monitor.
I use SharpCap in Livestacking mode mainly; I keep the unitary lights for further processing but I love the ability to enjoy the on-going acquisition

Here are my first feedbacks on the feature:
- in my case, the colour are better balanced after activating the effect, there is a shift upwards of the histogram (!), I don't understand why:

- Background level with no dark or flat : ~3500ADU (in RAW 16; taken from an ASI533 camera) [first attachment, only autostretch on mini histo, main histo is reset]
BG_nodark.jpg
BG_nodark.jpg (247.41 KiB) Viewed 2173 times
- Background level with dark + no background reduction : ~300ADU [2nd attachment]
BG_withdark.jpg
BG_withdark.jpg (251.27 KiB) Viewed 2173 times
- Background level with dark + now background reduction is activated : ~16500ADU [3rd attachment]
BG_withdark and with background reduction.jpg
BG_withdark and with background reduction.jpg (209.77 KiB) Viewed 2173 times

Having a sky background at 25% of the histogram is not really an issue, you have black and mid level to play with. My main issue was for the "final colour balancing", in the following capture, I made a strech with the mian histo in order to see the small discrepancies in background colour balance.
It is a full stack (54 images instead of 1 in the previous captures)

Usually, I make the colour fine tuning with the pad arrows, 0,02dB increment.
- one attachment with no colour adjustment : a little too much green in the sky backgroun
BG_withdark and with background reduction_fine colour balance 1.jpg
BG_withdark and with background reduction_fine colour balance 1.jpg (147.16 KiB) Viewed 2173 times
- one other attachment with -0,02dB on the green level : now the green is much too low !
BG_withdark and with background reduction_fine colour balance 2.jpg
BG_withdark and with background reduction_fine colour balance 2.jpg (155.46 KiB) Viewed 2173 times

My understanding is that the colour adjustment in the main histogram impacts the image before the "Background substraction" is applied and as a consequence the smallest colour adjustment have now a big impact which makes these adjustments not usuable

I don't know if these feedbacks are relevant as I was in folder monitor mode but I think so. In all the case, I think this feature will be very usefull, not only for the light polution but also when you use filters which may impact the colour balance between channel, in some cases the colour adjustment with the main histo may be tricky.

Best
Jean-Baptiste (from France)
France - Bonjour à tous !
Newton 150/750
iOptron CEM70
ASI533
User avatar
admin
Site Admin
Posts: 13125
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: New Feature : Background Subtraction

#18

Post by admin »

Hi,

perhaps if I explain the ordering of the different operations it will help show what is going on...

Adding a captured frame to the stack :

Frame Captured from Camera -> Dark Subtraction -> Flat Correction -> Background Removal
-> Alignment with stack -> Added to stack

Displaying the stack :

Stack Data -> Adjust channels using colour balance -> Live Stack Non-linear stretch from histogram black/mid/white levels -> Noise Reduction -> Sharpening -> Saturation adjustment -> Display Stretch -> Screen

What does this mean? Well first it's not a good idea to trust the pixel value readout as giving much of interest when you are using live stacking, since the readout will reflect the image that is coming out of the stack to be displayed, not the image captured from the camera (I think - I must admit I have not tested this combination!)

Secondly, you can see why the colour balance is so hard to adjust in your last images - because the colour balance adjustment comes before the non-linear stretch, and you've used a very strong stretch, the changes to colour balance are magnified by the stretching. I've always been a bit unsure about the 'correct' order of these two adjustments - since the colour balance is a linear adjustment it makes sense to put it before the non-linear stretch, but it does lead to the sort of over-sensitivity you noticed.

Finally, note that the background subtraction happens before the frames go into the stack, whereas the colour balance acts when the stack is being displayed, so the colour balance comes long after the subtraction.

Hope this helps

Robin
User avatar
Djibi
Posts: 6
Joined: Wed May 20, 2020 10:51 am

Re: New Feature : Background Subtraction

#19

Post by Djibi »

Yes, it helps because I was not aware in which order certain processing were made.

I mis-used the term "ADU value" sorry, I did not use the "ADU value tool" to mesure the outcome of my camera but to look at the value of the pixel of my calibrated frame. In PixInsight a have a value between 0 and 1, with this tool, I have a value between 1 and 65536 (16bits).
My point was to look at "what looks like a calibrated frame after background removal?"

this is why I displayed, using the livestacking windows, a "one frame only example".

- with nothing -> I see the light with no dark so the background level which is around 5% comes in fact from the camera offset I used at that gain, in that very specific example, the value of the pixel is the exact outcome of the frame generated by the camera (after RGGB Debayer)
- with dark substraction -> dark is doing its job, especially because it was made with the same camera offset, so now, we can say something like "black is black" ;) the value of a background pixel is close to zero
- the third and important one is the light + dark + background removal -> you can see now that the histogram of my calibrated frame has a peak around 25%

Thanks to you, I understand that my colour adjustment issue comes from the main histogram stretch, not the background removal.

So my point is : is this normal that the process you mention:
Frame Captured from Camera -> Dark Subtraction (-> Flat Correction // not done in my example) -> Background Removal
transform a background pixel in such a way ?

Perhaps I interpreted something in the wrong way but this seems strange, this looks like the background removal operation is "a division" rather than a substration; and in my specific case, it is a division by a small number ...
Perhaps, this is specific to the folder monitor camera that I was using and this won't happen when I test in "real life"
France - Bonjour à tous !
Newton 150/750
iOptron CEM70
ASI533
User avatar
admin
Site Admin
Posts: 13125
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: New Feature : Background Subtraction

#20

Post by admin »

Hi,

the background subtraction feature is a true subtraction, not a division. Note however that it doesn't move the background level down to zero as that would clip any pixels that happen to be below the average background level. Instead it moves the background level to 5% of max ADU (separate adjustment on each channel to ensure any colour cast to the background is removed).

If you test without live stacking active you should see this - if your background starts off below 5% then it will get boosted up to 5%.

cheers,

Robin
Post Reply