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 764614 - Add "smooth" mode to "Select -> Border"
Add "smooth" mode to "Select -> Border"
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal enhancement
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2016-04-04 20:38 UTC by Ell
Modified: 2016-05-09 21:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Comparison of the different border styles (80.34 KB, image/png)
2016-04-04 20:38 UTC, Ell
  Details
0001-app-Add-GimpChannelBorderStyle-enum.patch (2.72 KB, patch)
2016-04-04 20:39 UTC, Ell
none Details | Review
0002-app-Modify-gimp_gegl_apply_border-to-take-a-style-pa.patch (21.05 KB, patch)
2016-04-04 20:39 UTC, Ell
none Details | Review
0003-app-pdb-Modify-gimp_channel_border-to-take-a-style-p.patch (20.57 KB, patch)
2016-04-04 20:39 UTC, Ell
none Details | Review
0004-app-Handle-zero-radius-in-gimp_channel_border.patch (1.45 KB, patch)
2016-04-04 20:40 UTC, Ell
none Details | Review
0005-app-Add-Border-style-combo-to-the-Select-Border.-dia.patch (4.64 KB, patch)
2016-04-04 20:40 UTC, Ell
none Details | Review
0006-pdb-Modify-gimp-selection-border-to-use-BORDER_STYLE.patch (1.82 KB, patch)
2016-04-04 20:40 UTC, Ell
none Details | Review
0002-app-Modify-gimp_gegl_apply_border-to-take-a-style-pa.patch (20.68 KB, patch)
2016-04-05 14:16 UTC, Ell
none Details | Review
0003-app-pdb-Modify-gimp_channel_border-to-take-a-style-p.patch (20.28 KB, patch)
2016-04-05 14:16 UTC, Ell
none Details | Review

Description Ell 2016-04-04 20:38:38 UTC
Created attachment 325383 [details]
Comparison of the different border styles

As mentioned on IRC, we can get better-quality borders for selections by shrinking and growing the selection, and subtracting the shrunk selection from the grown selection.  This maintains antialiasing, and, more generally, better handles partial (i.e., non full-intensity) selections, as shown in the attached image.

This patch set replaces the "Feather border" toggle in the "Border Selection" dialog with a "Border style" combo, having three options: "Hard", "Smooth", and "Feathered".  "Hard" and "Feathered" correspond to the current behavior, with and without feathering, respectively; "Smooth" does what's described above, and is the default.

The `gimp-selection-border` procedure was hard coded to use a feathered border.  The last patch changes it to use the "Smooth" mode, which is probably more appropriate.

The fourth patch fixes a minor bug.
Comment 1 Ell 2016-04-04 20:39:21 UTC
Created attachment 325384 [details] [review]
0001-app-Add-GimpChannelBorderStyle-enum.patch
Comment 2 Ell 2016-04-04 20:39:37 UTC
Created attachment 325385 [details] [review]
0002-app-Modify-gimp_gegl_apply_border-to-take-a-style-pa.patch
Comment 3 Ell 2016-04-04 20:39:54 UTC
Created attachment 325386 [details] [review]
0003-app-pdb-Modify-gimp_channel_border-to-take-a-style-p.patch
Comment 4 Ell 2016-04-04 20:40:14 UTC
Created attachment 325387 [details] [review]
0004-app-Handle-zero-radius-in-gimp_channel_border.patch
Comment 5 Ell 2016-04-04 20:40:33 UTC
Created attachment 325388 [details] [review]
0005-app-Add-Border-style-combo-to-the-Select-Border.-dia.patch
Comment 6 Ell 2016-04-04 20:40:55 UTC
Created attachment 325389 [details] [review]
0006-pdb-Modify-gimp-selection-border-to-use-BORDER_STYLE.patch
Comment 7 Ell 2016-04-04 20:41:58 UTC
Note that the current border-width behavior (which the patches maintain) is slightly inconsistent.  In the general case, the border width is 2r+1 pixels, where r is the radius in the corresponding direction: one pixel at the "center" of the border, and r pixels on each side.  However, when, and only when, radius_x = radius_y = 1, the border width is just 1 pixel, instead of 3.  That is, when you type 1 in the entry box, you get a 1-pixel wide border, and when you type 2, you get a 5-pixel wide border; there's no way to get a 3-pixel wide border.

This is caused by an optimization in the border operation, specifically for this case (app/operations/gimpoperationborder.c:366).  I can't tell if this behavior is intentional, or an artifact of the optimization.  Either way, being able to select a 1-pixel border is useful, I'm just not sure the current way the radius maps to the border width is correct.  Either a 1-pixel border should be achieved with r=0, or the general case should be 2r-1, instead of 2r+1.
Comment 8 Michael Natterer 2016-04-04 22:16:05 UTC
Great :)
Comment 9 Ell 2016-04-05 14:16:22 UTC
Created attachment 325432 [details] [review]
0002-app-Modify-gimp_gegl_apply_border-to-take-a-style-pa.patch

Heh, a few bits from a different experiment managed to slip in.  Fixed.
Comment 10 Ell 2016-04-05 14:16:50 UTC
Created attachment 325433 [details] [review]
0003-app-pdb-Modify-gimp_channel_border-to-take-a-style-p.patch

ditto
Comment 11 Ell 2016-05-08 19:37:13 UTC
Fixed in master:

commit 2f96950eaa2cd866a1078b67de2c77f95d947e17
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 16:07:06 2016 +0000

    pdb: Modify gimp-selection-border to use BORDER_STYLE_SMOOTH

    instead of BORDER_STYLE_FEATHERD.

    Changes the behavior of the function, but probably for the better.

    This, and the previous 5 commits, fix bug 764614.

commit 60b31cce0f82f0287271c9b5a2c89629ae277b83
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 16:00:07 2016 +0000

    app: Add "Border style" combo to the "Select -> Border..." dialog

    instead of the "Feather border" toggle, and pass the selected style
    to gimp_channel_border().

    The border style defaults to "Smooth", whereas the previous default
    behavior corresponds to "Hard".

commit 8b11a505d95f53aa16045d8f7e42cdf9b5faca4c
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 17:25:45 2016 +0000

    app: Handle zero radius in gimp_channel_border()

    Can only be triggered through PDB.  Currently assigns illegal values
    to the GEGL ops' properties.

commit 15d4908076dcea5860f19099d907f0a0048e4aec
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 15:49:12 2016 +0000

    app, pdb: Modify gimp_channel_border() to take a style parameter

    isntead of the feather parameter, and pass it to
    gimp_gegl_apply_border().

    Make the necessary changes to the rest of the code to maintain the
    current behavior.

    Mass parameter alignment changes to gimpchannel.h. Sigh #2...

commit 45efe6c405345921f1cef33ffb779cf939c0ae07
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 15:11:05 2016 +0000

    app: Modify gimp_gegl_apply_border() to take a style parameter

    instead of the feather parameter.

    The BORDER_STYLE_HARD and BORDER_STYLE_FEATHERED styles are implemented
    using the "gimp:border" operation, as was done previously.  The
    BORDER_STYLE_SMOOTH style is implemented by performing a "gimp:grow" and
    a "gimp:shrink", and subtracting the shrunk image from the grown image
    using "gegl:substract".

    gimp_channel_border() is modified to pass either BORDER_STYLE_HARD or
    BORDER_STYLE_FEATHER, depending on its feather parameter, to maintain
    the current behavior.  The next commit replaces it with a style
    parameter as well.

    Mass parameter alignment changes to gimp-gegl-apply-operation.h.  Sigh...

commit 46a969035358deb8502f2d1c29e4bcb862bf9197
Author: Ell <ell_se@yahoo.com>
Date:   Mon Apr 4 14:53:56 2016 +0000

    app: Add GimpChannelBorderStyle enum

    Will be used as a parameter to control the behavior of
    gimp_channel_border(), and the corresponding "Select -> Border..."
    action, instead of the feather flag.

    Can be one of:

      - GIMP_CHANNEL_BORDER_STYLE_HARD: Current behavior, unfeathered.
      - GIMP_CHANNEL_BORDER_STYLE_SMOOTH: Smooth border, better handling
        partial selection, implemented as explained in the next commit.
      - GIMP_CHANNEL_BORDER_STYLE_FEATHERED: Current behavior, feathered.
Comment 12 josephbupe 2016-05-09 21:43:31 UTC
Great news! 

It would also be better if we could have a preview of the "Grow" and "Shrink" selection. At the moment it's a blind operation.

We have preview for Rectangle and Ellipse selections when you adjust the "Position" and "Size" in the options dialog, which unfortunately don't work for shrinked or grown selections.

REF: https://bugzilla.gnome.org/show_bug.cgi?id=755537