New script: GrayscaleDeepSNR

VicVP

New member
Nikita Misiura's DeepSNR module is a very powerful Deep-Learning based tool for denoising color images. However, it is currently only trained to run on color images, and does not work well on RGB-converted monochrome images.

The example below was converted from grayscale to RGB (left image). When you run DeepSNR on such a mono image, the algorithm will produce lot of artefacts (speckle noise, looks a bit like fake stars) and the denoise effect is not very strong.

Grayscale_convertToRGB.PNG


I figured this undesired effect was due to autocorrelation between the 3 channels of an RGB converted image. My script injects random noise in 2 channel copies to reduce autocorrelation, and then runs DeepSNR on the synthetic image. The extra noise results in a small loss of high-frequency detail, but it greatly improves the performance of DeepSNR on grayscale data without dedicated training of the network on monochrome images.

Dialog example.PNG


The strength parameter determines the amplitude of the injected noise. You may need to increase or decrease the default setting for optimal result, it is recommended to test a couple settings. NOTE: DO NOT run the script on a preview. It will crash and close your image. Testing strength settings goes very quickly if you first make a copy of the target image, then crop to 512x512 pixels.

Strength_Effect.PNG


The images of Messier 94 below show a comparison between the typical native DeepSNR performance on a real RGB image, and the script performance on a grayscale image derived from the same dataset.
  • Top left: starting RGB image (Messier 94)
  • Top right: red channel after applying native DeepSNR module on the RGB data
  • Bottom left: Extracted red channel from RGB, script applied with strength = 1
  • Bottom right: Extracted red channel from RGB, script applied with strength = 10

Native DeepSNR vs Script.PNG



The native DeepSNR result is extremely well denoised. Running the script with strength = 1 leaves visible artefacting, however sharpness is almost unaffected. Script strength 10 has much smoother noise reduction (much closer to the native DeepSNR result) at the cost of reduced sharpness in the galaxy core. With a proper mask, both images could be combined for the optimal denoise and sharpness.

This was my first time programming in JavaScript. I followed Roberto Sartori's video for the basics. Any suggestions for code improvement are very welcome! I hope this script is useful. If you test it on your own data, please share the results here.

Official page for DeepSNR process module: https://www.deepsnrastro.com/
 

Attachments

  • GrayscaleDeepSNR_v0_1.zip
    2.5 KB · Views: 134
Last edited:
Attention!

After downloading DeepSNR_Win_0.9.0_x64_update.zip, unzipping, copying into C:\Program Files\PixInsight\bin, starting PixInsight and searching for new modules, my AV software (Avira Security) moved my complete PixInsight installation into quarantine and PixInsight was terminated.

Looks like I'll have to delete the files and freshly install PixInsight.

Bernd
 
Thank you and of course thanks to Nikita for DeepSNR which I am using since it's release. It works brilliantly on my datasets and most of the times it is the only denoising tool I apply.
 
After downloading DeepSNR_Win_0.9.0_x64_update.zip, unzipping, copying into C:\Program Files\PixInsight\bin, starting PixInsight and searching for new modules, my AV software (Avira Security) moved my complete PixInsight installation into quarantine and PixInsight was terminated.
I directly reported DeepSNR-pxm.dll as false positive to Avira. Today they confirmed that the file is clean, and I now have no problem in installing and using the DeepSNR module any more. Like StarNet2, DeepSNR appears in the <Etc> process folder, and it benefits from CUDA GPU acceleration. I will try DeepSNR on my integrations.

Thanks a lot, Nikita!

Bernd
 
I fixed some minor bugs and added new features based on feedback.
The new version is attached as a zip.

Changes in v0.3
- Added parameter to replace target image or create new image.
- Strength setting now scales from 1 - 100 instead of 0.1 to 10.
- Added option in Dialog to run the script automatically with multiple Strength settings to quickly identify a good Strength value. This Quick test option is run on the central 512x512 pixel center of the image.

Changes in v0.2
- Added GNU licence text
- Prevent script from running on preview images.
- Prevent script from running on RGB images and notify user that DeepSNR should be used without this script.
- Prevent script from running on images smaller than 512x512 pixels.
- Added parameter to run on non-linear data.
- Added parameter to choose between AutoSTF or existing STF for DeepSNR.

Script test v0.3.PNG


Tweaking the Strength setting can take some time, so I added an option to make the script try different values of this parameter on a small patch of the input (as small as possible). This Quick test produces 3 small images, each will be named according to the applicable Strength value.

In the example below you can see that a Strength value of 3 is too low (small white dots) and a Strength value of 10 produces satisfactory denoising performance on this particular dataset.

Script v0.3 quick test feature.jpg



Any new feedback is welcome!
 

Attachments

  • GrayscaleDeepSNR.zip
    5.4 KB · Views: 107
Last edited:
Back
Top