/
clean-whiteboard-photo.scm
62 lines (58 loc) · 1.92 KB
/
clean-whiteboard-photo.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; clean-whiteboard-photo.scm --- Cleans up whiteboard Photographs to bring out the writing.
;;
;;
;; Copyright (C) 2009 Kyle R. Burton <kyle.burton@gmail.com>
;;
;; Author: Kyle R. Burton <kyle.burton@gmail.com>
;;
;; 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 <kyle.burton@gmail.com>"
;; 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")