-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDIEGO-invert-YUV.scm
73 lines (62 loc) · 2.35 KB
/
DIEGO-invert-YUV.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
;
; invert-YUV.scm
;
; Inverts the Luma channel (YCC colorspace) of a selected layer.
; (similar to the HSV Value invert, but without the color distortion)
;
; Copyright (C) 2008 "Stratadrake", [email protected]
;
; Version 0.0 05-23-2008 Written in GIMP 2.4.4
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
(define (script-fu-invert-YUV image drawable)
(if (= 0 (car (gimp-drawable-is-layer drawable)))
; then
(gimp-message "No active layer to perform this function on.")
; else
; (Note: YCbCr_ITU_R709 is specified here, but YCbCr_ITU_R470 or other YCC variants
; can also be used. There is a tiny variation in color tones between them)
(let* (
(temp-image (car (plug-in-decompose 1 image drawable "YCbCr_ITU_R709" 1)))
)
(gimp-image-undo-group-start image)
; Invert Luma layer
(gimp-invert (vector-ref (cadr (gimp-image-get-layers temp-image)) 0))
; Put it back together
(plug-in-recompose 1 temp-image drawable)
; Cleanup
(gimp-image-delete temp-image)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
; endif
)
)
)
(script-fu-register "script-fu-invert-YUV"
"Luma Invert"
"Inverts an image's YCC brightness \n file:DIEGO-invert-YUV.scm"
"'Stratadrake' ([email protected])"
"May 2008"
""
"RGB* "
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-invert-YUV"
"<Image>/Script-Fu/Colors/Components"
)