Skip to content

Add ROI processing and reinstate histogram dialog preview toggle (fixes #1098 and #1188)

Adrian Knagg-Baugh requested to merge roi into master

This is the start of a feature I originally hoped to do for 1.2 but kept putting off: ROI processing.

For some expensive image operations a user may want to experiment with processing only a region of interest until they are happy with the parameters of an operation. Denoising and deconvolution in particular can be very slow.

This MR introduces a ROI feature. The ROI can be set from the current selection (currently it is done manually, it could also be done automatically when a selection is drawn but I think this way offers more control).

The ROI is initially shown in pink in the same style as the selection. When a dialog is opened that supports use of ROIs, the ROI turns blue. I should probably add a log message too. If the ROI is active, image operations that support ROIs will only process the area within the ROI. This can be much quicker than processing the whole of gfit. The ROI supports siril_preview and undo operations.

Currently it works with the following operations:

  • asinh (doesn't really need it, but the code is simple so it was easy to add, it also proves that it works with operations making use of siril_preview).
  • Noise Reduction (significant time saver especially with some of the slower options like DA3D)
  • Deconvolution (huge time saver in trialling different options, but it doesn't speed up blind PSF estimation as that still needs to be done using the whole image)
  • Histogram dialog (i.e. both histogram and GHT stretches)
  • Color saturation (not really to improve speed, but using a ROI can be helpful to compare the effect in the ROI with the unmodified image)
  • Median filter (may help a little with speed, especially with large filter sizes on slower machines, but mainly it's for comparing the effect in the ROI with the unmodified image)
  • Remove green noise (mostly for comparison purposes, as above)

Support for ROI does need to be added to each image operation individually, but as can be seen from the MR it's easy to do: you just check for (!com.headless && gui.roi.active) and apply the operation to either &gfit or &gui.roi.fit as required. Operations without live previews require a little more tweaking to use the gfit_backup, but a clear example can be seen in src/filters/median.c There is an ability to add an image operation-specific callback that is called when the ROI changes or is cleared: for example this is used in histogram.c to update the HSL buffers if performing a Saturation stretch, and in operations with previews to ensure the preview synchronizes with the ROI when the ROI is changed. In any case, I think all the image operations currently in Siril that could benefit from ROI processing are now catered for.

All commands ignore the ROI, even if run from the GUI command line. This is for consistency and simplicity but also conceptually ROI processing is intended as a quick preview for slow operations, whereas commands are intended to apply to the whole image. If a ROI is present while a command is run it will simply be ignored, not cleared, so it will be available for future ROI-aware operations.

MR Changelogs are updated and there is an accompanying documentation MR.

TODO: update Deconvolution (done), Noise Reduction (done), Median Filter (done) and SCNR (done) dialogs to use the gfit_backup so that ROI processing can behave more intuitively without having to undo the ROI processing, clear the ROI and reapply to the whole image. (All done now.)

Edited by Adrian Knagg-Baugh

Merge request reports