1998-04-09 12:32:04 +00:00
|
|
|
;;; unsharp-mask.scm
|
1998-11-25 21:18:26 +00:00
|
|
|
;;; Time-stamp: <1998/11/17 13:18:39 narazaki@gimp.org>
|
|
|
|
;;; Author: Narazaki Shuji <narazaki@gimp.org>
|
|
|
|
;;; Version 0.8
|
1998-04-09 12:32:04 +00:00
|
|
|
|
1998-11-25 21:18:26 +00:00
|
|
|
(define (script-fu-unsharp-mask img drw mask-size mask-opacity)
|
2006-10-16 01:08:54 +00:00
|
|
|
(let* (
|
|
|
|
(drawable-width (car (gimp-drawable-width drw)))
|
|
|
|
(drawable-height (car (gimp-drawable-height drw)))
|
|
|
|
(new-image (car (gimp-image-new drawable-width drawable-height RGB)))
|
|
|
|
(original-layer (car (gimp-layer-new new-image
|
|
|
|
drawable-width drawable-height
|
|
|
|
RGB-IMAGE "Original"
|
2017-01-09 20:37:30 +01:00
|
|
|
100 LAYER-MODE-NORMAL)))
|
2008-01-15 05:15:08 +00:00
|
|
|
(original-layer-for-darker 0)
|
|
|
|
(original-layer-for-lighter 0)
|
2018-05-12 12:13:12 -04:00
|
|
|
(blurred-layer-for-darker 0)
|
|
|
|
(blurred-layer-for-lighter 0)
|
2008-01-15 05:15:08 +00:00
|
|
|
(darker-layer 0)
|
|
|
|
(lighter-layer 0)
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1998-04-09 12:32:04 +00:00
|
|
|
(gimp-selection-all img)
|
1998-11-14 20:46:25 +00:00
|
|
|
(gimp-edit-copy drw)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable new-image)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer new-image original-layer 0 0)
|
1998-04-09 12:32:04 +00:00
|
|
|
(gimp-floating-sel-anchor
|
2006-10-16 01:08:54 +00:00
|
|
|
(car (gimp-edit-paste original-layer FALSE)))
|
2004-01-26 15:34:47 +00:00
|
|
|
|
1998-04-09 12:32:04 +00:00
|
|
|
(set! original-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
|
|
|
|
(set! original-layer-for-lighter (car (gimp-layer-copy original-layer TRUE)))
|
2018-05-12 12:13:12 -04:00
|
|
|
(set! blurred-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-visible original-layer FALSE)
|
1998-04-09 12:32:04 +00:00
|
|
|
(gimp-display-new new-image)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1998-04-09 12:32:04 +00:00
|
|
|
;; make darker mask
|
2018-05-12 12:13:12 -04:00
|
|
|
(gimp-image-insert-layer new-image blurred-layer-for-darker 0 -1)
|
2007-10-01 08:42:48 +00:00
|
|
|
(plug-in-gauss-iir RUN-NONINTERACTIVE
|
2018-05-12 12:13:12 -04:00
|
|
|
new-image blurred-layer-for-darker mask-size TRUE TRUE)
|
|
|
|
(set! blurred-layer-for-lighter
|
|
|
|
(car (gimp-layer-copy blurred-layer-for-darker TRUE)))
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer new-image original-layer-for-darker 0 -1)
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-layer-set-mode original-layer-for-darker LAYER-MODE-SUBTRACT)
|
1998-04-09 12:32:04 +00:00
|
|
|
(set! darker-layer
|
2006-10-16 01:08:54 +00:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-name darker-layer "darker mask")
|
|
|
|
(gimp-item-set-visible darker-layer FALSE)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1998-04-09 12:32:04 +00:00
|
|
|
;; make lighter mask
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer new-image original-layer-for-lighter 0 -1)
|
2018-05-12 12:13:12 -04:00
|
|
|
(gimp-image-insert-layer new-image blurred-layer-for-lighter 0 -1)
|
|
|
|
(gimp-layer-set-mode blurred-layer-for-lighter LAYER-MODE-SUBTRACT)
|
1998-04-09 12:32:04 +00:00
|
|
|
(set! lighter-layer
|
2006-10-16 01:08:54 +00:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-name lighter-layer "lighter mask")
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1998-04-09 12:32:04 +00:00
|
|
|
;; combine them
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-visible original-layer TRUE)
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-layer-set-mode darker-layer LAYER-MODE-SUBTRACT)
|
1998-11-25 21:18:26 +00:00
|
|
|
(gimp-layer-set-opacity darker-layer mask-opacity)
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-visible darker-layer TRUE)
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-layer-set-mode lighter-layer LAYER-MODE-ADDITION)
|
1998-11-25 21:18:26 +00:00
|
|
|
(gimp-layer-set-opacity lighter-layer mask-opacity)
|
2010-08-03 00:13:51 +03:00
|
|
|
(gimp-item-set-visible lighter-layer TRUE)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-enable new-image)
|
2006-10-16 01:08:54 +00:00
|
|
|
(gimp-displays-flush)
|
|
|
|
)
|
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 13:27:27 +00:00
|
|
|
(script-fu-register "script-fu-unsharp-mask"
|
2006-10-23 09:05:58 +00:00
|
|
|
"Unsharp Mask..."
|
|
|
|
"Make a new image from the current layer by applying the unsharp mask method"
|
2006-10-16 01:08:54 +00:00
|
|
|
"Shuji Narazaki <narazaki@gimp.org>"
|
|
|
|
"Shuji Narazaki"
|
|
|
|
"1997,1998"
|
|
|
|
""
|
2006-10-18 12:34:52 +00:00
|
|
|
SF-IMAGE "Image" 0
|
|
|
|
SF-DRAWABLE "Drawable to apply" 0
|
2006-10-20 17:55:14 +00:00
|
|
|
SF-ADJUSTMENT _"Mask size" '(5 1 100 1 1 0 1)
|
|
|
|
SF-ADJUSTMENT _"Mask opacity" '(50 0 100 1 1 0 1)
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|