Popular Posts

Sunday, April 10, 2011

Rotoscope Effect: Photo effect using the Gimp.

Rotoscope Effect:
This will turn a photo into a RotoScope effect:

Here is the code -->
;***************************************************************************************
; RotoScope script for GIMP 2.x
;***************************************************************************************
(define (script-fu-RotoScope
        img
        drawable
    )
    (gimp-undo-push-group-start img)
    (if (= (car (gimp-drawable-has-alpha drawable)) TRUE)
        (begin
            (gimp-image-flatten img)
            (set! drawable (car (gimp-image-get-active-layer img)))
        )
    )
    (let*    (
            (width (car (gimp-drawable-width drawable)))
            (height (car (gimp-drawable-height drawable)))
            (img2 (car (gimp-image-new width height 0)))
            (tones (car (gimp-layer-new-from-drawable drawable img2)))
            (layer0 (car (gimp-layer-new-from-drawable drawable img)))
            (layer1 (car (gimp-layer-new-from-drawable drawable img)))
            (layer2 (car (gimp-layer-new-from-drawable drawable img)))
            (layer3 (car (gimp-layer-new-from-drawable drawable img)))
            (layer4 (car (gimp-layer-new-from-drawable drawable img)))
            (save-color (car (gimp-context-get-foreground)))
        )
        (gimp-image-add-layer img2 tones -1)
        (gimp-image-add-layer img layer4 -1)
        (gimp-image-add-layer img layer3 -1)
        (plug-in-despeckle RUN-NONINTERACTIVE img layer3 (* width .003) 1 -1 256)
        (plug-in-dog RUN-NONINTERACTIVE img layer3 (* height .002 7.5) (* width .002 .3) TRUE TRUE)
        (gimp-threshold layer3 246 255)
        (gimp-layer-set-mode layer3 MULTIPLY-MODE)
        (gimp-image-add-layer img layer2 -1)
        (gimp-image-add-layer img layer1 -1)
        (gimp-layer-set-mode layer1 SATURATION-MODE)
        (gimp-layer-set-mode layer2 COLOR-MODE)
        (gimp-layer-set-opacity layer1 67.0)
        (gimp-layer-set-opacity layer2 76.0)
        (gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 3 FALSE FALSE "0")
        (gimp-edit-copy tones)
        (gimp-floating-sel-anchor (car (gimp-edit-paste layer4 0)))
        (gimp-image-merge-down img layer3 0) ;lines
        (gimp-image-merge-down img layer2 0) ;saturation
        (gimp-image-merge-down img layer1 0) ;color
        (gimp-context-set-foreground '(0 0 0))
        (gimp-image-add-layer img layer0 -1)
        (gimp-by-color-select layer0 '(0 0 0) 10 0 2 0 0 0)
        (gimp-drawable-fill layer0 WHITE-FILL)
        (if (= (car (gimp-selection-is-empty img)) FALSE)
            (gimp-bucket-fill layer0 FG-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
        )
        (gimp-context-set-foreground save-color)
        (gimp-selection-clear img)
        (gimp-layer-set-mode layer0 MULTIPLY-MODE)
        (gimp-image-merge-down img layer0 0) ;black info.
        (set! layer4 (car (gimp-image-get-active-layer img)))
        (gimp-image-convert-rgb img2)
        (gimp-edit-copy layer4)
        (gimp-floating-sel-anchor (car (gimp-edit-paste tones 0)))
        (gimp-image-convert-indexed img2 NO-DITHER MAKE-PALETTE 32 FALSE FALSE "0")
        (gimp-edit-copy tones)
        (gimp-floating-sel-anchor (car (gimp-edit-paste layer4 0)))
        (gimp-image-delete img2)
        (gimp-layer-set-name layer4 "RotoScope")
        (gimp-undo-push-group-end img)
        (gimp-displays-flush)
    )
)

(script-fu-register
 "script-fu-RotoScope"
 _"<Image>/Script-Fu/Artistic/RotoScope"
 "Creates a RotoScoped Effect."
 ""
 ""
 "2011"
 "RGB* GRAY*"
 SF-IMAGE "Image"     0
 SF-DRAWABLE "Drawable" 0
)


Rotoscope

No comments:

Post a Comment