Ringing and Deringing

General discussion about StarTools.
Post Reply
Mike in Rancho
Posts: 1166
Joined: Sun Jun 20, 2021 10:05 pm
Location: Alta Loma, CA

Ringing and Deringing

Post by Mike in Rancho »

What are they? :confusion-shrug:

This is primarily an SVD related query, I'd think, though I believe Shrink has some deringing also..

I know there's a Wikipedia out there on Ringing, and maybe Goss something or other, not that it helped me very much, and Juan has an example page where he discusses it some but good golly -- PI deconvolution looks about as much fun as a tooth extraction. :shock:

For ST purposes though, what is the genesis of ringing artifacts? Is it a matter of the mathematics? Or the perturbations of a PSF, which on a graph can look like little up and down waves away from the central peak? Initially I had thought perhaps it arose from a dearth of "actual data" surrounding a star that's been deconvolved inward, that data having been blocked off by the previously spread out light blob of the star. But now I'm not so sure. :think:

Then of course, to handle that ringing, we have deringing. :? Is that also mathematical, or a localized backing off of deconvolution, or just a cosmetic repair of some sorts?

The curiosity comes from more reading about BXT-this-and-that. The fact that real deconvolution can artifact, which as I understand is typically ringing, seems an excuse for whatever kinds of artifacts BXT may go and introduce. But I figured ringing and deringing have been around a while and are thus perhaps well understood. Just not by me. :lol:
User avatar
admin
Site Admin
Posts: 3382
Joined: Thu Dec 02, 2010 10:51 pm
Location: Melbourne
Contact:

Re: Ringing and Deringing

Post by admin »

Ok, the genesis of ringing artifacts (that Wikipedia article is really useful/excellent) in deconvolution is not a terribly easy one to explain, so here goes.

This following video explains the Gibbs phenomenon in 1D.

Before watching that all you need to know that any signal can be decomposed into sine waves of different frequencies of different amplitudes. It's pretty neat and is closely related to the ways MP3 and also JPEG work; these lossy compression algorithms identify the most "important" sine waves to approximate the signal and throw away the rest of the sine waves. In the case of the latter, by reducing the amount sine waves ("frequency components") that need to be stored to reconstruct the signal, you can save a lot of space. The reconstructed signal won't be perfect, but close enough.

In the video, the Sinc function to the right is showing which sine waves make up the signal.
The function to the left ("time domain"/1D or "spatial domain"/2D if we're talking images) is signal as you're used to (a pixel, a blip, etc.).

https://www.youtube.com/watch?v=Ol0uTeXoKaU

The sine-wavy wobble in the signal is "ringing". Now that you have a feel for what is happening, you can appreciate that even if you really closely model the inverse of the PSF (which we want to iteratively convolve with to achieve deconvolution) and get everything as close to perfect as possible, the Gibbs phenomenon means that you will never be able to quite get rid of the ringing; the overshoot will remain but will just get sharper at best.

Like in the worst-case example in the video (a square pulse), the ringing is particularly noticeable when dealing with sharp transitions. Conversely it is barely visible/noticeable in smoother signals. A point light - like a star - is the worst possible scenario; against a pure black background, it's the sharpest transition imaginable.

Given that Richardson & Lucy deconvolution is iterative, one inverse-convolution result builds on the next, over multiple iterations. Ringing therefore compounds and causes worse and worse sharp transitions, themselves causing ringing and so on and so forth.

De-ringing then, is just a blanket term for any and all measures that try to counter, mitigate or hide the propagation of these ringing artefacts.

There are a number of strategies at work in StarTools that are "objective" measures and don't require user intervention (an important one is the intra-iteration resampling; this intentionally includes ringing artifacts into the PSFs so that they are reversed during the next iteration). The de-ringing parameter in StarTools, however, is a user-controllable parameter that attempts to detect "aesthetic" ringing, areas that have changed "too much" visually (yay for Tracking!) from the original and where the original is blended back in.

I hope this helps at all!
Ivo Jager
StarTools creator and astronomy enthusiast
Mike in Rancho
Posts: 1166
Joined: Sun Jun 20, 2021 10:05 pm
Location: Alta Loma, CA

Re: Ringing and Deringing

Post by Mike in Rancho »

Yikes! :shock:

Maybe this one of those mysteries better left unsolved, as they say. But the attempt is appreciated. :thumbsup:

The Wikipedia stuff lost me when they started talking about filters. Clearly they don't mean my Optolongs. ;)

I got about a third of the way through the video. Perhaps it's basic and remedial, I have no idea, but even so seems to presuppose some sort of signal processing background. Of which I have none.

I may have to keep poking around. Deconvolution and Gibbs for Dummies!

:(
User avatar
admin
Site Admin
Posts: 3382
Joined: Thu Dec 02, 2010 10:51 pm
Location: Melbourne
Contact:

Re: Ringing and Deringing

Post by admin »

Mike in Rancho wrote: Sat Jan 21, 2023 6:23 pm Yikes! :shock:

Maybe this one of those mysteries better left unsolved, as they say. But the attempt is appreciated. :thumbsup:
Apologies - I didn't mean to overwhelm or make things look harder than they are (that's not to say it's all trivial, but it should hopefully be "grokkable" by a more seasoned StarTools user with some help and further study)
The Wikipedia stuff lost me when they started talking about filters. Clearly they don't mean my Optolongs. ;)
You are already quite familiar with filters/frequencies. :)
For example, a Gaussian blur in the Layer module is a filter that is used all over the place in image processing.
As you apply the blur filter you should see fine detail blur away. Fine detail is "high frequency" (it changes fast from one location to the next adjacent location, or in Wipe parlance; it "undulates" fast). Or in other words, a Gaussian blur filters out high frequency signal. Or in yet other words, a Gaussian blur passes low frequency signal and is thus a type of low-pass filter.
The blur kernel size controls the frequency that is filtered out. Increase the blur size and lower and lower frequencies are filtered out.

You can actually construct a high pass filter too in the Layer module.
Given that a Gaussian filters out high frequency detail, we can get just the high frequency detail by subtracting the blurred image from the original image. We just made a high pass filter.

Does that help with the "filter" thing?
I got about a third of the way through the video. Perhaps it's basic and remedial, I have no idea, but even so seems to presuppose some sort of signal processing background. Of which I have none.
I appreciate it may all look/sound a bit math-y. However being an ST user, you actually have a fair bit of knowledge of the practical implications of all that is being discussed, perhaps without realizing it. Despite some terms being unfamiliar, you may spot some familiar things or concepts.

If not clear; whenever you see a 2D graph (for example like this one demonstrating the Gibbs phenomenon) that is said to be in the "time domain"...
Untitled.jpg
Untitled.jpg (2.94 KiB) Viewed 4328 times
...you are just looking at a horizontal (or vertical) single-pixel slice of an image (horizontal axis x or y coordinate), with the amplitude (vertical axis) being a grayscale value.
I may have to keep poking around. Deconvolution and Gibbs for Dummies!
Please do! Any questions, do let me know.

Interesting side note; the Wikipedia article highlights the Airy disc pattern (under special functions) as a PSF that has a ringing-like pattern. Ergo, this specific type of "ringing" already occurs naturally in our images (it's one of the reasons why the Super Structure module uses an Airy Disc convolution!).
Ivo Jager
StarTools creator and astronomy enthusiast
Mike in Rancho
Posts: 1166
Joined: Sun Jun 20, 2021 10:05 pm
Location: Alta Loma, CA

Re: Ringing and Deringing

Post by Mike in Rancho »

Thanks, Ivo. :D

Yes, further study needed. And who knew I was unwittingly being taught these things just by using ST? ;)

Sadly I do have a math minor, though that's ancient history, but this seems more of a specialty and has a bit of it's own language. In fact until I started AP a few years ago, I knew squat about Photoshop, image processing, layers, etc. etc. When I first downloaded Gimp my eyes bugged out. What is all this stuff!?

So when I see things like "kernel," I think - isn't that the low level inside my CPU? :lol:

And when the guy split up his charts into "time" on one side and something else on the other, and then talked about "convolving," I just threw up my hands.

Indeed a little more ST learning should help. I just read through the user notes for Layer (since it seems to involve a lot of this very type of stuff) and realized how much I need to catch up on.

In any event...without realizing I had jumped in way over my head, the genesis of it all was a (I presumed false) equivalency between artifacting in BXT and true deconvolution. As in, hey, deconvolution can cause artifacts too! So, my going theory was that true deconvolution artifacts, primarily ringing, to my knowledge, have to be pretty well understood - at least by the experts. And that does seem to be the case.
User avatar
admin
Site Admin
Posts: 3382
Joined: Thu Dec 02, 2010 10:51 pm
Location: Melbourne
Contact:

Re: Ringing and Deringing

Post by admin »

Mike in Rancho wrote: Mon Jan 23, 2023 8:04 am Thanks, Ivo. :D

Yes, further study needed. And who knew I was unwittingly being taught these things just by using ST? ;)

Sadly I do have a math minor, though that's ancient history, but this seems more of a specialty and has a bit of it's own language. In fact until I started AP a few years ago, I knew squat about Photoshop, image processing, layers, etc. etc. When I first downloaded Gimp my eyes bugged out. What is all this stuff!?

So when I see things like "kernel," I think - isn't that the low level inside my CPU? :lol:

And when the guy split up his charts into "time" on one side and something else on the other, and then talked about "convolving," I just threw up my hands.
While advanced math is useful in some cases, it's indeed more of a question of getting to know the terms/jargon and basic thinking/processes.

Convolving in the spatial domain (e.g. of an X by Y pixel image as you're used to) is as simple as this;

Given a filter kernel that looks like, for example, this;

1 2 1
2 4 2
1 2 1

Then the "new" target pixel in the image at location X, Y will become;

pixel value at (X-1, Y-1) x 1
+ pixel value at (X, Y-1) x 2
+ pixel value at (X+1, Y-1) x 1
(we just processed the top row of the filter kernel)

+ pixel value at (X-1, Y) x 2
+ pixel value at (X, Y) x 4 <--- yup, that's our original pixel going into the mix as well
+ pixel value at (X-1, Y-1) x 1
(we just processed the middle row of the filter kernel)

+ pixel value at (X-1, Y+1) x 1
+ pixel value at (X, Y+1) x 2
+ pixel value at (X+1, Y+1) x 1
(we just processed the bottom row of the filter kernel)

The new value will need to be corrected ("normalized"), by simply dividing it by the total of the filter values, which in this case is 16 (1+2+1+2+4+2+1+2+1). (we could also just use fractions in the filter of course, so that everything adds up to 1.0).

Congratulations, you just convolved a pixel by a 3x3 filter kernel! This way of convolving is really just taking a weighted average of the immediate vicinity of a pixel. This particular filter is (due to its specific weights/numbers) a Gaussian kernel, aka a "Gaussian blur". There are a massive amount of other useful kernels (different numbers, different sizes besides 3x3) with useful properties. And of course, the by now familiar "PSF" is also a kernel just like the others; a point light at a location in our image is "filtered" by this kernel. Deconvolution then, is attempting to reverse this filtering.

As you can see a lot of the "scariness"/math tends to melt away into a puddle of basic addition, subtraction, multiplication and division. It does get a little more esoteric when you start venturing into "frequency domain" and Fourier transforms. Super interesting and useful(!) in their own right, but it's possible to understand the bulk of what's going on without delving into that.
In any event...without realizing I had jumped in way over my head, the genesis of it all was a (I presumed false) equivalency between artifacting in BXT and true deconvolution. As in, hey, deconvolution can cause artifacts too! So, my going theory was that true deconvolution artifacts, primarily ringing, to my knowledge, have to be pretty well understood - at least by the experts. And that does seem to be the case.
Your hunch is definitely correct. It is indeed a false equivalency. Ringing is indeed well understood, as are the "artefacts" it creates. The "artefacts" - if any - are distinct and are easily identifiable, as opposed to something that was - by design - made to look like plausible detail.
Ivo Jager
StarTools creator and astronomy enthusiast
Mike in Rancho
Posts: 1166
Joined: Sun Jun 20, 2021 10:05 pm
Location: Alta Loma, CA

Re: Ringing and Deringing

Post by Mike in Rancho »

Thanks again for going above and beyond. :obscene-drinkingcheers:

I did find a Wikipedia on Convolution, which had a subsection and hyperlink to use in image processing, so I will have to find the time to read those. Or what I can dig out from amongst the forest of formulae such Wikpedia articles love to throw up there.

Still a little lost on convolving - function applied to function, but what about the original "hard" data? - and kernel, or is it window, but I'll try to read up on these definitions that will likely be a key to understanding.

But that aside for now, while I of course knew that deconvolution is attempting to reverse the blur of atmosphere and optics, it appears you are explaining that said atmosphere and optics are actually acting as a filter on the incoming data, hence convolving it into what lands on our sensor, in a spatially variant ;) manner.

I further take it that these effects, along with artifacts like ringing, are just a part of this, and thus happen in the analog arena - meaning we aren't dealing with effects from digitizing or quantization.

But then again, what is our signal to begin with - analog (waves) or digital (photons)? :D

Anyway, I am now pointed in some good directions for further study. :thumbsup:
decay
Posts: 497
Joined: Sat Apr 10, 2021 12:28 pm
Location: Germany, NRW

Re: Ringing and Deringing

Post by decay »

admin wrote: Fri Jan 20, 2023 11:36 pm This following video explains the Gibbs phenomenon in 1D.
:thumbsup: Thank you Ivo, for the insights and for link to the video.

I never heard of the Gibbs phenomenon before. The guy in this video does a really great job explaining this, it’s a real joy watching and hearing it. I wish I had teachers like him back in the past. And again I realised, that I’m too old school in some things. I’m always looking for something written down, but in this case a video is really helpful.

Oh and yes – you should write a book. I wonder, which level such a book should address. I have the impression, that there’s a gap between superficial writings and academic literature. The former often isn’t helpful at all and the latter often presumes extensive knowledge (of course, due to the nature of the topics).

At least I would buy your book. :)
Mike in Rancho wrote: Tue Jan 24, 2023 7:17 am Anyway, I am now pointed in some good directions for further study.
Mike, if you are thinking of further studies, it could be helpful to start with Fourier transformations of periodic signals, for example a square wave. It’s a real eye opener drawing and adding some of the sine wave components on paper and to see how the square wave is constructed. And you will see overshooting, as depicted in the graph on that Wikipedia article – but this time you will get a real feeling, how this overshooting arises.

This ‘sliding’ between time/spatial and frequency domains is incredibly elegant and powerful – and yes, the first time I saw this I threw my hands up, just like you described. But if you go on there will be a point in time at which you will simply ‘believe’ it and use it – just like with many other things you learned in the past.

Best regards, Dietmar.
dx_ron
Posts: 288
Joined: Fri Apr 16, 2021 3:55 pm

Re: Ringing and Deringing

Post by dx_ron »

This has been interesting. I doubt I will ever get sufficiently motivated to get to where I can describe deconvolution in terms of filter kernels, but there are connections that I had not previously appreciated.

The main one being the word "ringing" itself. Long, long before I took up astrophotography my main hobby was amateur radio. From that I was quite familiar with the concept of ringing in an RF filter, where it actually has a "ringing" sound when you apply a narrow RF filter to a CW (Morse code) signal. At some combination of higher Morse speed (more transitions from on-off-on) plus increasingly narrower filter it becomes impossible to distinguish on vs off and the discrete 'dits' and 'dahs' all run into each other.
Post Reply