-
Notifications
You must be signed in to change notification settings - Fork 463
/
ColorChannels.pde
46 lines (34 loc) · 922 Bytes
/
ColorChannels.pde
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
import gab.opencv.*;
OpenCV opencv;
PImage src, r, g, b, h, s, v;
int imgH, imgW;
void setup() {
src = loadImage("green_object.png");
src.resize(800,0);
opencv = new OpenCV(this, src);
size(1200, 672);
imgH = src.height/2;
imgW = src.width/2;
r = opencv.getSnapshot(opencv.getR());
g = opencv.getSnapshot(opencv.getG());
b = opencv.getSnapshot(opencv.getB());
opencv.useColor(HSB);
h = opencv.getSnapshot(opencv.getH());
s = opencv.getSnapshot(opencv.getS());
v = opencv.getSnapshot(opencv.getV());
}
void draw() {
background(0);
noTint();
image(src, imgW,0, imgW, imgH);
tint(255,0,0);
image(r, 0, imgH, imgW, imgH);
tint(0,255,0);
image(g, imgW, imgH, imgW, imgH);
tint(0,0,255);
image(b, 2*imgW, imgH, imgW, imgH);
noTint();
image(h, 0, 2*imgH, imgW, imgH);
image(s, imgW, 2*imgH, imgW, imgH);
image(v, 2*imgW, 2*imgH, imgW, imgH);
}