; ; laplace-adjust.scm - Get edges using the laplace filter, adjustable ; to get fine edges (lots of detail) to coarse edges (broader strokes) ; ; ;;; -------------------------------------------------------------------- ;;; version 0.1 by Jeff Trefftzs ;;; - Initial relase ;;; version 0.2 Raymond Ostertag ;;; - ported to Gimp 2.0, changed menu entry ;;; ;;; -------------------------------------------------------------------- ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Helper function to create a new layer ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (copylayer layer layername) (set! new (car(gimp-layer-copy layer 1))) ; Add an alpha channel (gimp-drawable-set-name new layername) new ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; This script combines the idiom of a saturation layer and a color ;;; layer, used also in the illustration.scm script and several others, ;;; with the idea of variable edge detection using the laplace edge ;;; detection filter. Laplacian edges are more or less detailed in ;;; inverse proportion to the degree of blurring that takes place before ;;; the filter is invoked. ;;; ;;; The appearance of the final image depends greatly on the background ;;; color that is chosen. Darker colors lead to darker images - which ;;; can serve nicely to highlight the lighter regions of the original. ;;; ;;; It's also worthwhile trying various levels of blur on the saturation ;;; layer, particularly if the original image had regions of great ;;; darkness. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (script-fu-laplace-adjust inImage inLayer inRadius inColor) (let* ( (oldfg (car (gimp-palette-get-foreground))) (whitelayer (copylayer inLayer "Solid Background")) (edgelayer1 (copylayer inLayer "Edge Layer 1")) (satlayer (copylayer inLayer "Saturation Layer")) (colorlayer (copylayer inLayer "Color Layer")) ) (gimp-image-undo-group-start inImage) ;; Real work goes in here (gimp-image-add-layer inImage whitelayer -1) (gimp-palette-set-foreground inColor) (gimp-drawable-fill whitelayer FOREGROUND-FILL) (gimp-image-add-layer inImage edgelayer1 -1) (gimp-drawable-set-visible edgelayer1 TRUE) (if (> inRadius 0) (plug-in-gauss-iir 1 inImage edgelayer1 inRadius TRUE TRUE) ) (plug-in-laplace 1 inImage edgelayer1) (if (< GRAY-IMAGE (car (gimp-image-base-type inImage))) ; RGB* image? (gimp-desaturate linelayer) ; then desaturate it ()) (gimp-image-add-layer inImage satlayer -1) ; the saturation layer (gimp-layer-set-mode satlayer SATURATION-MODE) ; saturation (gimp-image-add-layer inImage colorlayer -1) (gimp-layer-set-mode colorlayer COLOR-MODE) ; color (gimp-palette-set-foreground oldfg) (gimp-image-set-active-layer inImage inLayer) ) (gimp-image-undo-group-end inImage) (gimp-displays-flush) ) (script-fu-register "script-fu-laplace-adjust" _"/Script-Fu/Line-Art/Adjustable Laplacian Edges..." "Gets Laplacian edges by blurring a copy of the original and then invoking the laplacian edge plug-in. Larger blur values lead to coarser edges." "Jeff Trefftzs" "Copyright 2001, Jeff Trefftzs" "June 21, 2001" "RGB* GRAY* INDEXED*" SF-IMAGE "The Image" 0 SF-DRAWABLE "The Layer" 0 SF-ADJUSTMENT "Fine (0 <----> 64) Coarse" '(5 0 64 1 5 0 1) SF-COLOR "Background Color" '(128 128 128) )