1998-04-09 20:32:04 +08:00
|
|
|
;;; unsharp-mask.scm
|
1998-11-26 05:18:26 +08:00
|
|
|
;;; Time-stamp: <1998/11/17 13:18:39 narazaki@gimp.org>
|
|
|
|
;;; Author: Narazaki Shuji <narazaki@gimp.org>
|
|
|
|
;;; Version 0.8
|
1998-04-09 20:32:04 +08:00
|
|
|
|
1998-11-26 05:18:26 +08:00
|
|
|
(define (script-fu-unsharp-mask img drw mask-size mask-opacity)
|
2006-10-16 09:08:54 +08: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"
|
|
|
|
100 NORMAL-MODE)))
|
2008-01-15 13:15:08 +08:00
|
|
|
(original-layer-for-darker 0)
|
|
|
|
(original-layer-for-lighter 0)
|
|
|
|
(blured-layer-for-darker 0)
|
|
|
|
(blured-layer-for-lighter 0)
|
|
|
|
(darker-layer 0)
|
|
|
|
(lighter-layer 0)
|
2006-10-16 09:08:54 +08: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 21:27:27 +08:00
|
|
|
|
1998-04-09 20:32:04 +08:00
|
|
|
(gimp-selection-all img)
|
1998-11-15 04:46:25 +08: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 21:27:27 +08:00
|
|
|
|
1999-10-17 08:07:55 +08: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 21:27:27 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
(gimp-image-add-layer new-image original-layer 0)
|
1998-04-09 20:32:04 +08:00
|
|
|
(gimp-floating-sel-anchor
|
2006-10-16 09:08:54 +08:00
|
|
|
(car (gimp-edit-paste original-layer FALSE)))
|
2004-01-26 23:34:47 +08:00
|
|
|
|
1998-04-09 20:32:04 +08: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)))
|
|
|
|
(set! blured-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-set-visible original-layer FALSE)
|
1998-04-09 20:32:04 +08: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 21:27:27 +08:00
|
|
|
|
1998-04-09 20:32:04 +08:00
|
|
|
;; make darker mask
|
|
|
|
(gimp-image-add-layer new-image blured-layer-for-darker -1)
|
2007-10-01 16:42:48 +08:00
|
|
|
(plug-in-gauss-iir RUN-NONINTERACTIVE
|
|
|
|
new-image blured-layer-for-darker mask-size TRUE TRUE)
|
1998-04-09 20:32:04 +08:00
|
|
|
(set! blured-layer-for-lighter
|
2006-10-16 09:08:54 +08:00
|
|
|
(car (gimp-layer-copy blured-layer-for-darker TRUE)))
|
1998-04-09 20:32:04 +08:00
|
|
|
(gimp-image-add-layer new-image original-layer-for-darker -1)
|
2004-02-03 19:46:27 +08:00
|
|
|
(gimp-layer-set-mode original-layer-for-darker SUBTRACT-MODE)
|
1998-04-09 20:32:04 +08:00
|
|
|
(set! darker-layer
|
2006-10-16 09:08:54 +08:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-set-name darker-layer "darker mask")
|
|
|
|
(gimp-drawable-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 21:27:27 +08:00
|
|
|
|
1998-04-09 20:32:04 +08:00
|
|
|
;; make lighter mask
|
|
|
|
(gimp-image-add-layer new-image original-layer-for-lighter -1)
|
|
|
|
(gimp-image-add-layer new-image blured-layer-for-lighter -1)
|
2004-02-03 19:46:27 +08:00
|
|
|
(gimp-layer-set-mode blured-layer-for-lighter SUBTRACT-MODE)
|
1998-04-09 20:32:04 +08:00
|
|
|
(set! lighter-layer
|
2006-10-16 09:08:54 +08:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-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 21:27:27 +08:00
|
|
|
|
1998-04-09 20:32:04 +08:00
|
|
|
;; combine them
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-set-visible original-layer TRUE)
|
2004-02-03 19:46:27 +08:00
|
|
|
(gimp-layer-set-mode darker-layer SUBTRACT-MODE)
|
1998-11-26 05:18:26 +08:00
|
|
|
(gimp-layer-set-opacity darker-layer mask-opacity)
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-set-visible darker-layer TRUE)
|
2004-02-03 19:46:27 +08:00
|
|
|
(gimp-layer-set-mode lighter-layer ADDITION-MODE)
|
1998-11-26 05:18:26 +08:00
|
|
|
(gimp-layer-set-opacity lighter-layer mask-opacity)
|
2003-12-04 00:39:32 +08:00
|
|
|
(gimp-drawable-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 21:27:27 +08:00
|
|
|
|
1999-10-17 08:07:55 +08:00
|
|
|
(gimp-image-undo-enable new-image)
|
2006-10-16 09:08:54 +08:00
|
|
|
(gimp-displays-flush)
|
|
|
|
)
|
|
|
|
)
|
2004-11-19 06:44:28 +08: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 21:27:27 +08:00
|
|
|
(script-fu-register "script-fu-unsharp-mask"
|
2006-10-23 17:05:58 +08:00
|
|
|
"Unsharp Mask..."
|
|
|
|
"Make a new image from the current layer by applying the unsharp mask method"
|
2006-10-16 09:08:54 +08:00
|
|
|
"Shuji Narazaki <narazaki@gimp.org>"
|
|
|
|
"Shuji Narazaki"
|
|
|
|
"1997,1998"
|
|
|
|
""
|
2006-10-18 20:34:52 +08:00
|
|
|
SF-IMAGE "Image" 0
|
|
|
|
SF-DRAWABLE "Drawable to apply" 0
|
2006-10-21 01:55:14 +08: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 09:08:54 +08:00
|
|
|
)
|