;;; ca-correction.scm ;;; ;;; Fix transverse chromatic aberrations (TCA) caused by dispersion of the lens ;;; material. ;;; The image will be separated into RGB channels. Then the channels will be ;;; scaled relative to the center of the image (blown up). ;;; ;;; Tested with GIMP versions 2.0 and 2.2 (define (drawable-scale-radially drawable scale interpolate?) (if (not (= scale 1.0)) (let ((x (* 0.5 (car (gimp-drawable-width drawable)))) (y (* 0.5 (car (gimp-drawable-height drawable))))) ;; apply correct function for GIMP-2.0 (if (< (string->number (car (gimp-version))) 2.2) (gimp-transform-2d drawable interpolate? x y scale scale 0.0 x y) (gimp-drawable-transform-2d-default drawable x y scale scale 0.0 x y interpolate? FALSE)) (gimp-layer-resize-to-image-size drawable)))) (define (script-fu-ca-correction image drawable scale-red scale-blue interpolate?) (let* ((smallest (min scale-red 1.0 scale-blue)) (decomposed-images (plug-in-decompose RUN-NONINTERACTIVE image drawable "RGB" FALSE)) (red-image (car decomposed-images)) (green-image (cadr decomposed-images)) (blue-image (caddr decomposed-images)) (red-drawable (car (gimp-image-get-active-drawable red-image))) (green-drawable (car (gimp-image-get-active-drawable green-image))) (blue-drawable (car (gimp-image-get-active-drawable blue-image)))) (drawable-scale-radially red-drawable (/ scale-red smallest) interpolate?) (drawable-scale-radially green-drawable (/ 1.0 smallest) interpolate?) (drawable-scale-radially blue-drawable (/ scale-blue smallest) interpolate?) (gimp-display-new (car (plug-in-drawable-compose RUN-NONINTERACTIVE -1 red-drawable green-drawable blue-drawable -1 "RGB"))) (gimp-displays-flush))) (script-fu-register "script-fu-ca-correction" "/Script-Fu/Alchemy/Chromatic Aberration Correction..." "Fix chromatic aberrations (CA) caused by dispersion of the lens material." "Bernd Beuster" "Public Domain" "July 4, 2005" "" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-VALUE "Scale Factor Red" "1.0" SF-VALUE "Scale Factor Blue" "1.0" SF-TOGGLE "Interpolate (system default)" TRUE) ;;; vim:ts=2:sts=2:et