After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 792848 - Enhancement: Domain-Transform Operation
Enhancement: Domain-Transform Operation
Status: RESOLVED OBSOLETE
Product: GEGL
Classification: Other
Component: operations
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Default Gegl Component Owner
Default Gegl Component Owner
Depends on:
Blocks:
 
 
Reported: 2018-01-23 22:41 UTC by Felipe Kersting
Modified: 2018-05-22 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Git's Patch (18.40 KB, patch)
2018-01-23 22:41 UTC, Felipe Kersting
none Details | Review
New Patch v2 (24.01 KB, patch)
2018-01-31 19:46 UTC, Felipe Kersting
none Details | Review

Description Felipe Kersting 2018-01-23 22:41:31 UTC
Created attachment 367344 [details] [review]
Git's Patch

This patch is the submission of a new operation, the domain-transform filter.

The domain-transform filter is similar to a generic bilateral filter. However, it generates very good results in a much shorter period of time.

Original Article: http://inf.ufrgs.br/~eslgastal/DomainTransform/Gastal_Oliveira_SIGGRAPH2011_Domain_Transform.pdf

The filter may be parallelized in the future, improving even more its speed.
Comment 1 Øyvind Kolås (pippin) 2018-01-24 17:23:49 UTC
Thank you for this op, as it is I think this operation still needs work before we include it in the default install, perhaps we could stick it in the workshop folder for now so that more people can opt-in to playing with and improving it before adding it among the ops in common.

First, the copyright statements in the top should be changed to your email and name, and we in GIMP/GEGL code the coding style is to prefer spaces over tabs
in files.

On small images the results are nice, fast good and interesting - however on really big images, the operation ends up allocating a temporary linear buffer the size of the image, which might be optimal for speed on small images, but for high resolution imagery.. this big memory allocation followed by blocking processing makes it not well suited for interactive use, for instance in GIMP - where one might run out of memory, the ui freeze up and work be lost.

Interspersed with the processing, some (infrequent) calls to gegl_operation_progress would make it less blocking.

From quickly looking over the implementation, it looks like it is traversing the image by scanlines and by pixel columns in multiple passes. Maybe using gegl_buffer_get() with rectangles corresponding to scanlines / pixel columns would work well for this, fetching a scanline/column are optimized cases for GeglBuffer.

If the operation would produce correct results with either an extra neighbourhood of radius, or radius * 4, the filter would be able to use the automatic multi-threading that is being opted out of with operation_class->threaded = FALSE;
Comment 2 Felipe Kersting 2018-01-26 16:53:21 UTC
Thank you very much for your feedback Øyvind Kolås.

We are working to fix the problems you mentioned and we will submit a new patch soon.

With regards to the automatic multi-threading, unfortunately there is no way to use it in this operation. The domain-transform is being implemented as a recursive filter; each pixel depends on all pixels in the same line or column. Further more, the filter must be applied several consecutive times. There is a way to parallelize the domain-transform, but it requires a more complex implementation.

However, we will avoid allocating a temporary linear buffer the size of the image, by using GeglBuffer functions, as you suggested.

Thanks,
Felipe
Comment 3 Felipe Kersting 2018-01-31 19:46:33 UTC
Created attachment 367734 [details] [review]
New Patch v2
Comment 4 Felipe Kersting 2018-01-31 20:00:26 UTC
Hello,

I've submitted a new patch in which I fixed the following items:

- Moved the operation to the workshop
- Changed copyrights
- Replaced tabs by spaces
- Avoided big memory allocations
- Used gegl_operation_progress as requested

Now, the operation is not allocating a buffer which has the size of the original image. Instead, the op is using a buffer of size DIMENSION * BLOCK_STRIDE * 4, where DIMENSION is image_width or image_height (the bigger one) and BLOCK_STRIDE is being defined as 1. This new approach worsens filter performance a bit, since the domain-transforms are being calculated dynamically.

About gegl_operation_progress calls, we noticed that for normal images (images that are not very big) the filter runs almost instantly. So, when using the filter inside GIMP with these images, the progress bar would not be necessary. We used glib's timer to call gegl_operation_progress only when necessary, i.e. only when the operation is taking too long.

Waiting for your feedback

Thanks
Comment 5 Øyvind Kolås (pippin) 2018-02-02 10:46:03 UTC
Since the operation has been moved to the workshop I will push the commit before finding time to play around more with it. In the workshop it more easily gets wider testing. 

One thing I do wonder, is whether 'domain-transform' is a name that will make sense for regular operators of GIMP, or if we are adding yet another rather technical implementation name like "bilateral filter" or "unsharp mask" that at least confuse new users.
Comment 6 Alexandre Prokoudine 2018-02-02 11:30:42 UTC
The original paper lists more applications than smoothing/denoising :) How about a more specific name such as "Smoothing by Domain Transform" or smth like that?
Comment 7 Felipe Kersting 2018-02-16 15:57:09 UTC
Hello,

Thanks for pushing the commit!

With regards to the filter name, yes, maybe a more specific name would fit better. "Smoothing by Domain Transform" seems to be a good one :)
Comment 8 GNOME Infrastructure Team 2018-05-22 12:21:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gegl/issues/61.