jimz
Posts: 10
Joined: Tue Apr 21, 2020 7:05 pm

HQ camera banding in night sky 20s -ag 16 exposure

Fri Jun 26, 2020 7:34 pm

I want near-real-time night sky photos for use in a web page. Limiting exposures to 20s makes star tracks mostly not discernable (2.8mm lens). The jpg straight from raspistill with -ag set to maximum 16 still looks black except for just a few stars. Postprocessing using convert-level sets the lowest few brightness levels to black, makes any pixel brighter than ~26 (stars) white, and stretches the rest; the Milky Way becomes visible (and auroras as well hopefully).

These two commands from a shell created the following image.

Code: Select all

raspistill -t 10 -md 3 -bm -st -ex off -ag 16 -dg 1 -ss 20000000 -awb off -awbg 2.1,2.4 -drc med -o HQ1_200625_0315.jpg  
convert HQ1_200625_0315.jpg -level 0.5%,10%,1.2 HQ1l_200625_0315.jpg 
HQ1l_200625_0315_2028.jpg
HQ1l_200625_0315_2028.jpg (142.21 KiB) Viewed 2353 times
HQ1l_200625_0315_2028.jpg

Banding is especially visible in the middle right side of the image. Note that for -ag 16 banding is visible in other images even if none of ‘ -awb off -awbg 2.1,2.4 -drc med’ is specified.

I put the camera in the dark and made two images ~5 hours apart using

Code: Select all

raspistill -t 10 -md 3 -bm -st -ex off -ag 16 -dg 1 -ss 20000000 -o black.jpg
and then gimp-levels-whitepoint=7 to show the darkest 8 levels. To my eye the patterns from the two different times look different, i.e. patterns are transient, and the images look different on left from right while banding is almost not present in the middle.
dark7_5h_20.jpg
dark7_5h_20.jpg (120.38 KiB) Viewed 2353 times
‘black’ jpgs in same environment 5h apart

I averaged over all pixels in each line to form simple line averages of each of RGB values in black.jpg. While no large amplitude single frequency seemed persistent top to bottom there is a very-regular 4-line frequency of brightness oscillation albiet with very low amplitude of <0.1 (of 0-255); e.g. average blue value for line numbers 1400-1600 is shown just below. (In images with ‘-drc med’ the amplitude of the 4-line oscillation looks about 4 times larger).
blackperBlue.jpg
blackperBlue.jpg (94.49 KiB) Viewed 2353 times


Sky photos are taken ~50 feet from house in a very rural setting with no outdoor lighting (nearest ‘street light’ is ~1/4 mile away) where it is powerd by 5v from a 16800mah battery pack. HQ and Zero are in PVC enclosure and Zero board LED is off.

Why does the banding occur?
Why does the low-amplitude 4-line brightness oscillation occur?
I need -ag 16 for short 20s exposures to have enough light to show the Milky Way: can I use the max analog gain (16) but still eliminate transient banding?
Increasing ‘black point’ post processing can eliminate banding but though discrete stars remain, the Milky Way mostly disappears.

CanPi
Posts: 64
Joined: Wed May 20, 2020 12:21 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Fri Jun 26, 2020 9:10 pm

Banding at maximum gain is unusual. I am not an expert on ASTRO but one thing one realizes about Pi cameras when looking through the libcamera manual is how much processing is being done in the background.

Have you tried going raw with the - r switch or even better raspiraw? In addition there is a recent thread on how to kill the DPC (aka Star Eater) algorithm.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 31876
Joined: Sat Jul 30, 2011 7:41 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Fri Jun 26, 2020 9:25 pm

I'm having trouble thinking of a way the ISP could introduce banding like that. So my suspicion is that it is some artefact of the sensor itself. Its transient, so I wonder if there are certain areas on the die that are more susceptible to noise, and those areas are band like. Complete guess though.

The suggestion to try raw is good one.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 648
Joined: Tue Jan 07, 2020 9:15 am

Re: HQ camera banding in night sky 20s -ag 16 exposure

Fri Jun 26, 2020 10:34 pm

Hi, if you were able to capture a jpeg+raw file (same raspistill runes, but also with -r) and share it somewhere, I'd be interested to take a look. Probably disable the on-sensor DPC (this thread: viewtopic.php?f=43&t=277768). Thanks!

jimz
Posts: 10
Joined: Tue Apr 21, 2020 7:05 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Fri Jun 26, 2020 10:54 pm

I will add -r tonight.
RAW, as unix has been, is just one more of those things to get around to.

jimz
Posts: 10
Joined: Tue Apr 21, 2020 7:05 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sat Jun 27, 2020 4:59 pm

I was moving stuff around last night and did not disable DPC and the neglected to remove my -awb & -awbg settings but -drc was not on.
That said, I put a few files captured w/ -r at
https://drive.google.com/drive/folders/ ... sp=sharing

Code: Select all

raspistill -t 10 -md 3 -bm -st -ex off -ag 16 -dg 1 -ss 20000000 -awb off -awbg 2.1,2.4 -r -o HQw$fdt
Banding is not apparent in last night's images. There are no trees at the edges (where banding has been most pronounced) of the view either.

I will do again tonight and try to have DPC off.

Over the coming days the moon will become prominent and problematic for dark skies until it rises ever later after it is full.

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 648
Joined: Tue Jan 07, 2020 9:15 am

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sat Jun 27, 2020 9:09 pm

I had a quick bash at processing one of those raw files, you can find the results here: https://drive.google.com/drive/folders/ ... sp=sharing

There are two versions. One, dubbed "minimal", applies as little processing as possible to the file (no denoise, no DPC) and is therefore a pretty good representation of what's in the raw file.

The other, dubbed "best", adds what I believe to be a plausible level of denoise and a little sharpening. It still shows many more faint stars than the original jpeg. Generally I found there was little scope to stretch the histogram down the bottom end before the noise became visually quite disturbing (at least to my eyes, perhaps astronomical eyes are different!).

Anyway, I think that should give you an idea of what's achievable, but you'd have to do the raw processing for yourself. Also, as per the DPC thread, you should get better results if you turn off the on-sensor DPC, but you'll have to calibrate and remove the hot pixels for yourself too before passing through dcraw (or tool of choice).

If you can grab a capture without the on-sensor DPC, I can put those through the same processing.

I can't really say why you got all this banding originally, but then it didn't reappear. Sometimes pixels or rows in sensors can share components that can give rise to systematically correlated behaviour, but I have no idea in this case. I certainly got the impression that with all the gain and then histogram stretching, we're pushing the raw data really quite far. Could it have been that in some of the captures you'd been running the sensor longer than in others? Sorry not to be more help on this one.

jimz
Posts: 10
Joined: Tue Apr 21, 2020 7:05 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sat Jun 27, 2020 10:25 pm

Banding is still the concern.

Last night the Zero was just about out of range of any wifi; I don't think it was connected to one all night. I don't know what effect that might have on fluctuations in energy use but on all other nightly tests the zero has been continuously tethered to a WiFi connection.

It has occurred to me that as Zero activity fluctuates that current variations could produce micro fluctuations in supply voltages. I don't know the possibility of an irregular ripple in supply affecting reference voltages used by ADC.

jimz
Posts: 10
Joined: Tue Apr 21, 2020 7:05 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sat Jun 27, 2020 11:28 pm

I am not getting DPC to disable.

Code: Select all

pi@RPiZero2:~ $ sudo vcdbg set imx477_dpc 0
Could not parse address/symbol specifier

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 648
Joined: Tue Jan 07, 2020 9:15 am

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sun Jun 28, 2020 8:38 am

Hi again, you're sure you've done sudo rpi-update?

nicolap8
Posts: 713
Joined: Mon Mar 13, 2017 9:45 pm

Re: HQ camera banding in night sky 20s -ag 16 exposure

Sun Jun 28, 2020 9:48 am

jimz wrote:
Sat Jun 27, 2020 11:28 pm
I am not getting DPC to disable.

Code: Select all

pi@RPiZero2:~ $ sudo vcdbg set imx477_dpc 0
Could not parse address/symbol specifier
Typo: use "-dpc" not underscore!

Return to “Camera board”