; LAB-sharpen.scm ; 0.2 (2004-08-17) ; 0.1 (2004-08-11) ; ; 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. ; ; LAB sharpen ; based on the tutorials ; http://www.gimpguru.org/Tutorials/ReducingCCDNoise/index.shtml ; http://www.gimpguru.org/Tutorials/SmartSharpening/index.shtml ; ; (C) 2004 by Thorsten Schnebeck (thorsten.schnebeck@gmx.net) ; ; copy this script to ~/.gimp/scripts/lab-sharpen.scm ; and in Gimp2: Xtns->Script-Fu->Refresh Scripts ; you find this script in Script-Fu/Alchemy/LAB-Sharpen... (define (spline) (let* ((a (cons-array 6 'byte))) (set-pt a 0 0 0) (set-pt a 1 143 106) (set-pt a 2 255 255) a)) (define (script-fu-lab-sharpen image drawable radius amount threshold denoise) (gimp-image-undo-group-start image) ; Build edge-mask (set! mask (car (gimp-image-duplicate image))) (set! drawable (car (gimp-image-get-active-drawable mask))) (plug-in-edge 1 mask drawable 1.7 1 0) (gimp-image-convert-grayscale mask) (plug-in-gauss-iir2 1 mask drawable 2 2) ; (gimp-curves-spline drawable 0 6 (spline)) (gimp-edit-copy drawable) (gimp-image-delete mask) ; Call a plugin to separate LAB-layers into a new image (set! drawable (car (gimp-image-get-active-drawable image))) (set! lab_image (car (plug-in-decompose 1 image drawable "LAB" 1))) (set! layers (gimp-image-get-layers lab_image)) (set! b_layer (aref (cadr layers) 0)) (set! a_layer (aref (cadr layers) 1)) (set! l_layer (aref (cadr layers) 2)) (gimp-drawable-set-visible a_layer 0) (gimp-drawable-set-visible b_layer 0) (gimp-image-set-active-layer lab_image l_layer) ; Selection channel (set! selection (car (gimp-channel-new lab_image (car (gimp-image-width image)) (car (gimp-image-height lab_image)) "Selection" 50 '(128 128 128)))) (gimp-image-add-channel lab_image selection 0) (gimp-floating-sel-anchor (car (gimp-edit-paste selection 0))) (gimp-selection-load selection) (gimp-image-remove-channel lab_image selection) (plug-in-unsharp-mask 1 lab_image l_layer radius amount threshold) (if (> denoise 0) (begin (gimp-selection-invert lab_image) (plug-in-gauss-iir2 1 lab_image l_layer denoise denoise) ) ) (set! compose (car (plug-in-drawable-compose 1 lab_image l_layer a_layer b_layer drawable "LAB"))) (gimp-edit-copy (car (gimp-image-get-active-drawable compose))) (gimp-image-delete lab_image) ; Flush the display (gimp-image-undo-group-end image) (gimp-displays-flush) (gimp-display-new compose) ; (gimp-display-new lab_image) ) (script-fu-register "script-fu-lab-sharpen" "/Script-Fu/Alchemy/LAB-Sharpen..." "LAB sharpen The better way to sharpen/denoise your digital images. http://www.gimpguru.org/Tutorials/SmartSharpening/index.shtml" "Thorsten Schnebeck" "Thorsten Schnebeck (thorsten.schnebeck@gmx.net)" "2004" "RGB*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT _"Radius" '(1.5 1 50 0.5 1 1 1) SF-ADJUSTMENT _"Amount" '(0.6 0 5 0.1 0.5 1 1) SF-ADJUSTMENT _"Threshold" '(2 0 5 0.5 1 1 1) SF-ADJUSTMENT _"Denoise" '(0 0 100 1 10 0 1) ) ;Tab=4