-
Notifications
You must be signed in to change notification settings - Fork 5
/
patdavid-color-decompose_0.3.scm
131 lines (102 loc) · 4.99 KB
/
patdavid-color-decompose_0.3.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
; Color Decompose v0.3
; Created by Patrick David <[email protected]>
; http://blog.patdavid.net
;
; Decompose a color image to channels using various
; decomposition methods. Will use the (possibly) most
; useful channels for a B&W conversion:
;
; RGB, Value, Lightness, CMY, (cmy)K, L(ab), Luma
;
; v0.2 CHANGES
; REVMOED CMY from output, as they are just inversions of RGB...
;
; 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.
(define (script-fu-patdavid-color-decompose Image Drawable)
(let*
(
(tmp 0)
(lyr 0)
)
(gimp-image-undo-group-start Image)
; RGB
(define tmp (plug-in-decompose 1 Image Drawable "RGB" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "RGB - Red")
(gimp-image-add-layer Image (car lyr) -1)
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car (cdr tmp)) )) Image) )
(gimp-item-set-name (car lyr) "RGB - Green")
(gimp-image-add-layer Image (car lyr) -1)
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car (cdr (cdr tmp))) )) Image) )
(gimp-item-set-name (car lyr) "RGB - Blue")
(gimp-image-add-layer Image (car lyr) -1)
; HSV - Value
(define tmp (plug-in-decompose 1 Image Drawable "Value" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "HSV - Value")
(gimp-image-add-layer Image (car lyr) -1)
; HSL - Lightness
(define tmp (plug-in-decompose 1 Image Drawable "Lightness" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "HSL - Lightness")
(gimp-image-add-layer Image (car lyr) -1)
; CMY
;(define tmp (plug-in-decompose 1 Image Drawable "CMY" 0))
;(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
;(gimp-item-set-name (car lyr) "CMY - Cyan")
;(gimp-image-add-layer Image (car lyr) -1)
;(gimp-invert (car lyr) )
;(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car (cdr tmp)) )) Image) )
;(gimp-item-set-name (car lyr) "CMY - Magenta")
;(gimp-image-add-layer Image (car lyr) -1)
;(gimp-invert (car lyr) )
;
;(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car (cdr (cdr tmp))) )) Image) )
;(gimp-item-set-name (car lyr) "CMY - Yellow")
;(gimp-image-add-layer Image (car lyr) -1)
;(gimp-invert (car lyr) )
; CMYK - K
(define tmp (plug-in-decompose 1 Image Drawable "CMYK" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car (cdr (cdr (cdr tmp)))) )) Image) )
(gimp-item-set-name (car lyr) "CMYK - K")
(gimp-image-add-layer Image (car lyr) -1)
(gimp-invert (car lyr) )
; LAB - L
(define tmp (plug-in-decompose 1 Image Drawable "LAB" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "LAB - L")
(gimp-image-add-layer Image (car lyr) -1)
; YCbCr ITU R470 256
(define tmp (plug-in-decompose 1 Image Drawable "YCbCr_ITU_R470_256" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "Luma - y470f")
(gimp-image-add-layer Image (car lyr) -1)
; YCbCr ITU R709 256
(define tmp (plug-in-decompose 1 Image Drawable "YCbCr_ITU_R709_256" 0))
(define lyr (gimp-layer-new-from-drawable ( car( gimp-image-get-active-layer (car tmp) )) Image) )
(gimp-item-set-name (car lyr) "Luma - y709f")
(gimp-image-add-layer Image (car lyr) -1)
(gimp-displays-flush)
(gimp-image-undo-group-end Image)
)
)
; Finally register our script with script-fu
(script-fu-register "script-fu-patdavid-color-decompose"
"Color Decompose..."
"Decompose to useful channels for B&W conversions"
"Patrick David <[email protected]>"
"Patrick David"
"2012-12-10"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-patdavid-color-decompose" "<Image>/Colors")