Created
January 15, 2015 04:07
-
-
Save lyoshenka/b656e5ba56c74fdd6b75 to your computer and use it in GitHub Desktop.
GIMP Script-Fu to clean up whiteboard photographs to bring out the writing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; clean-whiteboard-photo.scm --- Cleans up whiteboard Photographs to bring out the writing. | |
;; https://github.com/kyleburton/sandbox/blob/master/gimp/clean-whiteboard-photo.scm | |
;; | |
;; Copyright (C) 2009 Kyle R. Burton <[email protected]> | |
;; | |
;; Author: Kyle R. Burton <[email protected]> | |
;; | |
;; Commentary: | |
;; | |
;; Copy or symlink this into your gimp rc directory, which on most | |
;; Linuxes should be: | |
;; | |
;; $HOME/.gimp-V.v/scripts. | |
;; | |
;; On OS X you can copy or symlink this into: | |
;; | |
;; /Applications/Gimp.app/Contents/Resources/share/gimp/2.0/scripts | |
;; | |
;; It should register itself under the menu: | |
;; | |
;; <Toolbox>/Xtns/WhiteBoard | |
;; | |
;; On the Mac this seems to be Filters/WhiteBoard | |
;; | |
(define (cwb-get-top-layer theImage) | |
(let* ((layer-info (gimp-image-get-layers theImage)) | |
(num-layers (car layer-info)) | |
(layer-ids (cadr layer-info))) | |
(aref layer-ids 0))) | |
(define (clean-whiteboard-photo theImage) | |
(let* ((mainLayer (cwb-get-top-layer theImage)) | |
(blurLayer (car (gimp-layer-copy mainLayer 0)))) | |
(gimp-image-add-layer theImage blurLayer -1) | |
(plug-in-gauss 1 theImage blurLayer 25 25 0) | |
(gimp-invert blurLayer) | |
(gimp-layer-set-mode blurLayer DODGE-MODE) | |
(gimp-image-merge-down theImage blurLayer CLIP-TO-IMAGE) | |
(gimp-brightness-contrast (cwb-get-top-layer theImage) -100 80) | |
(gimp-drawable-set-visible (cwb-get-top-layer theImage) TRUE))) | |
(script-fu-register | |
;; name | |
"clean-whiteboard-photo" | |
;; menu label | |
"Clean Whiteboard Photo" | |
;; description | |
"Given a photo of a whiteboard, reduce background noise and bring out the writing and drawing." | |
;; author | |
"Kyle R. Burton <[email protected]>" | |
;; copyright | |
"Copyright 2009, Kyle R. Burton" | |
;; date created | |
"2009-09-17" | |
;; image type that it works on | |
"RGB" | |
;; rest are parameters [if any] | |
SF-IMAGE "The image" 0) | |
(script-fu-menu-register "clean-whiteboard-photo" "<Toolbox>/Xtns/WhiteBoard") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment