PixInsight Forum (historical)

PixInsight => Release Information => Topic started by: Juan Conejero on 2013 May 13 12:00:50

Title: TGVDenoise 1.0 Released
Post by: Juan Conejero on 2013 May 13 12:00:50
Hi everybody,

I am proud to announce that we have just released a new tool: TGVDenoise, written by PTeam member Carlos Milovic. All users have now access to this tool as a regular update to PixInsight 1.8.0 RC7.

TGVDenoise is a noise reduction tool based on total generalized variation (see references [1...5] at the end of this post), a novel signal processing concept with important applications to image regularization and restoration. As I anticipated in a previous post, TGVDenoise is the first one of a series of TGV-based tools that we have been working on during the last year. Other members of this series are a multiscale, spatially adaptive TGV noise reduction tool (SATGV), and an image restoration (deconvolution) tool. Hopefully we'll be releasing these modules during the next weeks and months. I would like to reiterate my congratulations to Carlos Milovic for his excellent research and development work on these tools.

In the rest of this post I'll describe briefly the main TGVDenoise parameters. We'll be posting noise reduction examples on this board during the next days.

Overview of the TGVDenoise tool

(http://pixinsight.org/images/forum/20130513/TGVDenoise/TGVDenoise.png)

The TGVDenoise tool has two separate sections: noise reduction parameters at the top side, and local support parameters at the bottom side. While we write an official documentation, let's describe briefly these sections and their corresponding parameters.

Noise Reduction Parameters

* Color working mode.

For color images, TGVDenoise provides two working modes: RGB/K and CIE L*a*b*. In RGB/K mode, the same set of parameters is applied to each nominal RGB channel, for color images, or to the nominal grayscale channel, for monochrome images. Note that for grayscale images the color working mode is irrelevant.

In CIE L*a*b* mode, the target image is first converted to the CIE L*a*b* color space. Lightness parameters (first tab) are then applied to the CIE L* component, and chrominance parameters (second tab) are applied to the CIE a* and b* components. Finally, the image is converted back to the RGB space. This mode allows you to apply a different (usually more aggressive) noise reduction procedure to the chrominance, which makes the tool more flexible and adaptable to a variety of typical denoising problems. You can disable one of the parameter sets, so you can apply noise reduction just to either the lightness or chroma components.

* Strength

This parameter controls the strength of the diffusion process that smoothens the image. Large values are more aggressive, while small values tend to give results that are more similar to the original image. You have to find a good balance between the strength and edge protection parameters (see below).

* Edge protection

This is by far the most critical parameter of the TGVDenoise tool. This parameter works as a threshold for the regularization process, preventing diffusion over edge features stronger than the threshold value. Hence, you use this parameter to prevent the noise reduction process from damaging significant image detail and features. Smaller values are more aggressive to protect edges against blurring caused by the diffusion process. Larger values are more permissive and lead to smoother images, but may cause some detail loss.

* Smoothness

Controls the continuity degree of smooth regions. Smaller values tend to preserve small-scale structures such as sharp edges, but also may generate staircase artifacts. The default value of 2 usually works well with most images, and you normally won't need to change it.

* Iterations

TGVDenoise emulates a diffusion process, following a dynamic evolution scheme. Each iteration can be seen as a time sample, where the image reaches a new state. The process converges to an optimal solution when no significant diffusion can happen between neighbor pixels. This usually requires a large number of iterations. Convergence is evaluated by calculating the norm of the difference between two consecutive iteration steps. This is an estimate of global error, or mean square change. Usually, once this difference drops below 1/255, little or no changes can be perceived in the displayed image.

Upon execution, TGVDenoise writes its final global error estimate to the console as a 'delta' value. You can watch these estimates to get an idea of how well the process is converging to an acceptable result. The default value of the iterations parameter (100 iterations) is a good starting point for most images.

* Automatic convergence

When automatic convergence is enabled, the process will be stopped if either the difference between two successive iterations (see the iterations parameter above) is smaller than the convergence parameter (see below), or if the maximum number of iterations is reached; whichever happens first. If this parameter is disabled, the specified number of iterations will always be performed, ignoring the convergence parameter.

Be aware that when automatic convergence is enabled, the TGVDenoise process is not previewable. In other words, since convergence is specific to the data being processed, there is no guarantee that the result obtained on a preview be the same as the result obtained on its mother image with the same parameters. Depending on the image, the differences can be significant. For this reason the automatic convergence parameter is disabled by default.

* Convergence

When automatic convergence is enabled, the TGVDenoise process will be stopped when the difference between two successive iterations becomes smaller than this value. See the information given for the iterations and automatic convergence parameters.

Local Support Parameters

A local support image changes the rate of the diffusion process, creating a spatially dependent function. This allows to better preserve high SNR areas, or to protect specific image edges. For deep-sky astronomical images, a local support is advisable to achieve optimal results, especially for linear images.

It is very important to point out that the local support image is not a mask. The support image should represent the signal-to-noise ratio of the target image, where higher pixel values will provide stronger protection. This effectively controls the dynamic properties and evolution of the TGV regularization process, but does not work by mixing processed and unprocessed pixels, so it has nothing to do with a mask. Of course, the TGVDenoise process is fully maskable, so you can apply it through a mask if you find it necessary, in addition to using (or not) a local support image.

* Preview

Enable this option to get a preview of the working local support image that will be used by TGVDenoise. This is a control mode that must be disabled to perform an actual noise reduction process.

* Support image

By default, the local support image is disabled. TGVDenoise performs outstandingly well for most images without the help of a local support. When enabled, the local support is the intensity component (in the HSI color system) of the target image by default, but you can select any grayscale image with the same geometry as the target view (or its mother image in the case of a preview). When SNR is proportional to illumination, as happens with deep-sky images, a local support can be of great help to drive the TGVDenoise process, as noted above.

* Noise Reduction

This is the number of small-scale wavelet layers that will be removed from the working local support image. For very noisy images, smoothing the local support may help to achieve more accurate results because this makes it less dependent on spurious small-scale variations.

* Midtones

This is the midtones balance parameter of a histogram transformation that will be applied to the working local support image. Use it to fine tune protection on moderately bright areas.

* Shadows

This is the shadows clipping point parameter of a histogram transformation that will be applied to the working local support image. Increase it to decrease protection on dark areas.

* Highlights

This is the highlights clipping point parameter of a histogram transformation that will be applied to the working local support image. Decrease it to increase protection on bright areas.

Important Notes

* TGVDenoise is a memory intensive process. Internally it requires 13 working duplicates of one channel of the target image in 32-bit floating point format, so it may easily cause out-of-memory errors on the 32-bit version of PixInsight for Windows. If this happens to you, the only solution is a 64-bit version of PixInsight running on a 64-bit operating system.

* TGVDenoise is processor-intensive. We have done our best to achieve the best optimized parallel implementation we are capable of, but despite this, the algorithm requires significant processing time for moderately large images. Since the process is fully previewable (please note: if the automatic convergence parameter is disabled), you should use relatively small previews defined on special interest areas of the image to find an optimal set of parameters, which you can apply to the whole image after testing them thoroughly.

* The strength, edge protection and smoothness parameters have been implemented as exponential controls on the TGVDenoise interface. We have already used exponential controls in the AdaptiveStretch tool. These controls allow you to work in scientific notation (http://en.wikipedia.org/wiki/Scientific_notation), which gives you quick and easier control for parameters with very large ranges. Each parameter is divided into four fields that work in tandem: a large edit field where you can enter the parameter's value directly, a small edit field to enter the coefficient in the range from 1 to 9.99, a slider to change the coefficient value with the mouse, and a spin box where you can define the exponent. In future versions of the TGVDenoise tool, most of these parameters will probably be implemented differently, once we improve our knowledge of their practical ranges.

References

[1] Florian Knoll, Kristian Bredies, Thomas Pock and Rudolf Stollberger. Second order total generalized variation (TGV) for MRI. Magnetic Resonance in Medicine 65(2):480-491, 2011.

[2] Kristian Bredies, Karl Kunisch and Thomas Pock. Total generalized variation. SIAM Journal on Imaging Sciences, 3(3):492-526, 2010.

[3] Kristian Bredies. Recovering piecewise smooth multichannel images by minimization of convex functionals with total generalized variation penalty. Submitted for publication, 2012.

[4] Kristian Bredies, Yiqiu Dong and Michael Hintermüller. Spatially dependent regularization parameter selection in total generalized variation models for image restoration. Submitted for publication, 2012.

[5] Chambolle, A., Pock, T. A first-order primal-dual algorithm for convex problems with applications to imaging. J. Math. Imaging Vis. 40, 120–145, 2011.
Title: Re: TGVDenoise 1.0 Released
Post by: alintolea on 2013 May 13 14:23:00
Yet another poorly documented tool... It's such a shame the only advice we get is "trial and error". I'm sure that for a certain image scale, seeing, pixel size = i.e. measurable or known quantities, and desired size of the protected features (in pixels or arcseconds), there are at least recommended starting values.

Pix is such a powerful software, plagued by sub standard documentation. Yes, after a while you get a "feeling", but in the meantime it torture.
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 14:42:18
look at the dates on those reference papers. look at the journal titles.

this is cutting-edge stuff. no one has any experience with this tool on astronomical images besides Juan and Carlos. how about trying to figure it out and post some ideas? should PITeam keep new processes a secret until they can write a cookbook?

cripes.
Title: Re: TGVDenoise 1.0 Released
Post by: multiweb on 2013 May 13 14:58:11
Can't seem to se PixInsight 1.8.0 RC7 in the update repository yet. Has it been posted yet? I'm on RC6.
Title: Re: TGVDenoise 1.0 Released
Post by: Coco on 2013 May 13 15:55:36
Excellent piece of software, I just tried it on an old OSC image of M33 and the results are dramatic..
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 16:26:46
Can't seem to se PixInsight 1.8.0 RC7 in the update repository yet. Has it been posted yet? I'm on RC6.

rc7 should be there, i've been using it for a couple of weeks... what platform are you on? come to think of it maybe it was not released for linux?


Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 13 16:33:13
It is not distributed as an update. You have to download it from the download central.
Title: Re: TGVDenoise 1.0 Released
Post by: Luigi on 2013 May 13 17:32:12
Get RC7 from 'download central.' Uninstall RC6 (save preferences as an icon first if you wish). Once RC7 is installed it will update from the update repository.
Title: Re: TGVDenoise 1.0 Released
Post by: Sean on 2013 May 13 19:06:31
Juan and Carlos,

Thanks for another cutting edge tool. I look forward to putting it through its paces.

Alin, you might be more comfortable with a different software package. For example, Photoshop has a large number of 1000 page books available on Amazon.

Sean
Title: Re: TGVDenoise 1.0 Released
Post by: Philip de Louraille on 2013 May 13 20:00:27
I look forward using this new tool and the ones coming! Many thanks for all the efforts!
Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 13 21:16:58
Thanks for your words. They are very encouraging. :) there is much left to do, so these next weeks/months will be highly active in the development department.
We'll be expecting your thoughs and results with the new tool!
Title: Re: TGVDenoise 1.0 Released
Post by: cfranks on 2013 May 13 21:24:15
Wow!  The following are small sections of the original images.  There are too few subs and therefore very noisy.  My attempt at boosting the central blue saturation is crude but I was reasonably happy.  Image01 is before, Image02 is after TVG!
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 21:24:57
i was trying this out on some terrestrial photos that were shot at high ISO - lots of shot noise. the results were encouraging but i kept losing detail. i'll have to keep fiddling with the parameters.

thanks for your hard work on this stuff, it is very interesting.

Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 13 21:30:26
Try lowering the strength. For the noise amplitude, as a starting point you may use the std dev of an uniform area in the image. Also using a local support may help.
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 21:57:27
i had used a strength < 9 to begin with, but then found that i had to increase the smoothing way too much to compensate for large areas of noise that the algorithm thought was structure. eventually i moved the strength up to about 15 and reduced the smoothing. but even at lower strengths i lost a lot of detail.

i did use local support and that helped a lot.

i think it is a very difficult image, iso 6400 and 1/250s at f/2.8 from a canon 7D.
Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 13 22:08:01
You may also try increasing the number of iterations. I think that 100 is quite a low number. 500 is much closer to the real convergence point of the algorithm. This may change in future releases, with multiscale aproaches. But, right now, try more iterations.
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 22:26:24
 8) okay. i had increased to 300 but i guess that was not enough. i'll keep fiddling.
Title: Re: TGVDenoise 1.0 Released
Post by: pfile on 2013 May 13 22:28:43
is there any advantage to working on a linear image with this process? the image in question has already been autostretched by lightroom and exported as tiff.
Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 13 22:59:19
I don't know :D

Mathematically, this algorithm (and most other ones) assumes constant gaussian noise. Linear astronomical images suffer from poisson noise mainly. So, in that case is mandatory to use a local support to help the algorithm to discriminate between different SNR zones. In stretched images something similar happens, but now the noise distribution is not as easy described. Also, noise amplitudes in the shadows are larger than on the highlights. So, fine tunning the parameters may be trickier, to protect real details in high snr areas. Again, the local support can make the difference, since it acts as a modulator of the strength parameter (inversally proportional, and in aspect similar to an snr map).

The bottom line. Using LS, both approaches should work. It remains to be seeing wich ones proves to be more user friendly, with easier parameters to fine tune. The next algorithm that is under production should create internally this support maps, and require only a first guess od the strenght that is not critical for the result. There is also an open development field, regarding spatially variable noise amplitudes. We'll get into that once all the current development codes are implemented as official releases, and there is still left some work to do.
Title: Re: TGVDenoise 1.0 Released
Post by: chris.bailey on 2013 May 14 00:38:20
Only given it a quick trial but does seem to do better than ACDNR in avoiding the dreaded blotchy background.
Title: Re: TGVDenoise 1.0 Released
Post by: Jules on 2013 May 14 01:25:42
Juan, Carlos

Thanks very much for the time and effort, just when I thought I was getting use to ACDNR :D

Julian
Title: Re: TGVDenoise 1.0 Released
Post by: MickyWay on 2013 May 14 03:27:26
Another super tool from the PI team.

It has all the sliders needed to reduce the dreaded noise and I find the default settings are a good starting point.

What other software offers improvements and support we continually enjoy with PI ? And at no extra cost !!

Thanks to all.....

Regards, Colin
Title: Re: TGVDenoise 1.0 Released
Post by: AstroScience on 2013 May 14 04:18:13
This is just getting better and better! Thank you for all the hard work.
Title: Re: TGVDenoise 1.0 Released
Post by: northern_nights on 2013 May 14 13:54:19
Guys:  I always appreciate your hard work at improving your software.  The sophistication and capability of PixInsight is simply remarkable.  You can made a blink person see the light (figuratively speaking of course).  Many years ago I would never have imagined that I could produce the astro images that were only attainable at world class observatories.

A truly loyal user of PI.
Title: Re: TGVDenoise 1.0 Released
Post by: AstroScience on 2013 May 16 02:08:37
Strange, I saw how PI downloaded the update, but after restart I can't find it anywhere.
Any ideas what went wrong? I'm on 1.8 RC7 Win 7 x64.
Title: Re: TGVDenoise 1.0 Released
Post by: Warhen on 2013 May 16 07:55:48
Hi guys, Thanks from me too for all your hard work in the past. I noticed the term 'diffusion' in Juan's post. This isn't the 'anisotropic diffusion' replacement for ACDNR that's been hinted at in the past is it?

I'd like to see the NR tools streamlined at some point. I'm a minimilist by nature and the choices seem overwhelming already. As we all know, one can spend an hour fine tuning any one process. Give me two great ones, rather than ATWT, MMT, ACDNR, GREYC, TGVDN, Anisotropic Diffusion...
That's just me.  FWIW, I find LRGBC's CNR very powerful!

Carlos can you compare TGVDN w/ say GREYC from a practicle standpoint- talk of algorithm's will be wasted on me. ;>)

Do you see TGV as a fine-finisher or as a primary denoiser?

Lastly, I find ACDNR's specific approach for chrominance noise to be something important for NR processes. I hope its replacement addresses this.

Thank you and keep up the work!
Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 16 08:22:51
Hi Warren. Yes, this is the replacement we talked about earlier. Indeed TGV may be interpreted as anisotropic diffusion, if we see the iterations as a time evolution. The main difference from TGV to other anisotropic diffusions (normal total variation, and graycstoration too, up to some degree) is that they assume that images are patches, of homogeneus pieces. In other words, images are piecewise constant. TGV, on the other hand, assumes that images are piecewise smooth. This is the advantage of TGV, and why it generates far less artifacts (like, staircaising).

I'm not an expert on the interns of GREYC, but I know that is based on TV, and tries to overcome the staircaising artifacts by using some big modifications to the main algoirithm. The "problem", is that it has been designed for daylight, normal images, with gaussian noise. In that sense, our implementation of TGV is more flexible, since it works with linear or nonlinear data, and the use of the local support frame adds the capability to deal with poisson noise.
Also, from the user point of view, I think that TGV may lead to some "lost of detail" compared to GREYC, since the piecewise constant constrain enhances more sharp edges. But at the same time, TGV will look far more natural, with smooth gradients, and will avoid some of the typical "weird pixels" that arise near sharp edges with GREYC. IMHO, TGV is on top of the wave right now, and it should be even more powerfull in future releases. We have a major upgrade under development, and have several research lines already plotted.

Now, about when to use TGV best... The truth is that we don't know yet. I think that both steps combined will prove to be a good choise. I would use it first at linear stage to smooth a bit the data (low strengths), to facilitate the first stretch and intensity adjustments. Then, I would use as a finisher, to really smooth the background and low signal features (up to taste).

ACDNR based its philosophy on SGBNR :) And yes, we kept that in TGV too. Luminance/Chrominance separation is crucial to many denoising problems. Nevertheless, if in linear stage, I should probably try working on RGB first. Just thinking as a purist. But, of course, you all will help us find the best uses and applications of this new tool. 
Title: Re: TGVDenoise 1.0 Released
Post by: mdemita on 2013 May 16 20:24:28
I cannot for the life of my find this tool in my release.  I am using 1.08.00.1015 (x64) RC7,  Any suggestions would be very welcome.

Thanks

Mike
Title: Re: TGVDenoise 1.0 Released
Post by: AstroScience on 2013 May 16 20:48:18
Mike, did you saw that PI downloaded that update?
If so, go to Process/Modules/Install Modules/
on the window that will open click on "Search" , it should find TGVDenoise module.
Click on "Install" and it should work.
I don't know why it didn't that automatically as always but installing manually works.
Title: Re: TGVDenoise 1.0 Released
Post by: Geoff on 2013 May 16 21:11:18
You could also try Resources>Updates>Check for Updates.
Worked for me.
Geoff
Title: Re: TGVDenoise 1.0 Released
Post by: xatamec on 2013 May 20 03:28:31
Something really strange happened to me. Yesterday I replaced my previous 1.8 version by the newer 1.8 RC7 just to install the TVGdenoise module and give it a try.
Everything worked ok, after installing 1.8RC7 a popup window informed about 7 available updates (one of them the TVGdenoise module), I installed them and restarted PI. Then the TVGdenoise module was there under NoiseReduction folder. I was trying it with an old image and got some promising results.
This morning I have started PI and the TVGdenoise module was not there any more, I can't find it under NoiseReduction neither under AllProcesses. Curiously, I click on "View Installed Updates" and it's there, but there's no way to find it under the process menu.
I'm running PI 64-bit version for Windows. Any help is welcome.
Title: Re: TGVDenoise 1.0 Released
Post by: Ioannis Ioannou on 2013 May 22 01:23:24
So far I resisted on the 1.8 RCxxxx upgrades, sticking with 1.7, but finally this tool got my attention and helped me to made my mind. I installed RC7 yesterday night and tried TGV on some (very noisy) Ha and O3 frames.

Indeed, it seems to be a very strong tool BUT, where is the preview button and where is the mask generator from ACDR ?   >:D

It is a really pain already due to lack of documentation, how about a real time preview window to assist us to experiment?  And no, applying to previews is not the same.  Com'on guys, you have the code from ACDR, reuse it and make this tool the best ever !!!  ;) (I may offer to assist in adding the code for free, but I'll have to figure out a few things first, long time when I had a compiler on my laptop :angel: )
Title: Re: TGVDenoise 1.0 Released
Post by: xatamec on 2013 May 24 06:42:24
Update on my previous post. I uninstalled PI RC7 and installed it again from scrath including the 7 updates and the TVGmodule is there again. I have closed and started PI several times and it keeps there. However it's very strange that it disappeared the first time.

Regarding the results yielded by the tool, I don't have a clear opinion yet. I tried many combinations of parameters and tried to fine-tune them the most, but it always produced a patchy background on my DSLR linear image. ACDNR did a lot better keeping a smoother and patches free background.

Sergi
Title: Re: TGVDenoise 1.0 Released
Post by: Carlos Milovic on 2013 May 24 08:07:58
Increase the number of iterations. Use 300 or 500. Then play only with the noise amplitude and strength parameters (in that order).
Title: Re: TGVDenoise 1.0 Released
Post by: adriano.valvasori on 2013 May 31 08:37:22
Hello everyone, I installed the latest updates but I can not see TGVDenoise despite being mentioned in the Installed Updates window.
Thank you.
Title: Re: TGVDenoise 1.0 Released
Post by: darkownt on 2013 May 31 09:37:58
Wow!  The following are small sections of the original images.  There are too few subs and therefore very noisy.  My attempt at boosting the central blue saturation is crude but I was reasonably happy.  Image01 is before, Image02 is after TVG!

cfranks:

I don't know if boosting the blues boosted the noise there.  Perhaps applying the TVG before applying the blue boost would lead to a more "homogeneous" noisiness in the final image.  I do enjoy the color!
Title: Re: TGVDenoise 1.0 Released
Post by: mads0100 on 2013 June 05 18:52:47
I find it can be a tad bit more subtle than ACDNR and I don't need to use a mask.  Is that what everyone else is finding out too?

Chris
Title: Re: TGVDenoise 1.0 Released
Post by: Jules on 2013 August 30 08:20:59
Hi

I have been looking at TGVDenoise since its release and it seems I am getting somewhere with it. Have a look at the attached for the settings I have been using.

Julian
Title: Re: TGVDenoise 1.0 Released
Post by: Nocturnal on 2013 August 30 14:19:02
Nice demo!