Hi guys,
I have the following code from Sadowski
I read from somewhere that the following source code just inverts the hue, but the saturation and brightness unchanged!!
I want to know is it correct to say this code just inverting the hue? Or to make this happen (just inverting the hue) I have to erase this two lines? or do I have to do something else?
float s = saturation(invert.pixels[i]);
float b = brightness(invert.pixels[i]);
Please advice.
-
PImage orig, gray, invert;
-
boolean inverted = false;
-
void setup() {
orig = loadImage("516031.JPG");
size(orig.width,orig.height);
gray = new PImage(orig.width,orig.height);
gray.copy(orig,0,0,orig.width,orig.height,0,0,orig.width,orig.height);
gray.filter(GRAY);
invert = new PImage(orig.width,orig.height);
invert.copy(orig,0,0,orig.width,orig.height,0,0,orig.width,orig.height);
invert.filter(INVERT);
colorMode(HSB);
invert.loadPixels();
for (int i = 0; i < invert.pixels.length; i++) {
float h = hue(invert.pixels[i]);
float s = saturation(invert.pixels[i]);
float b = brightness(invert.pixels[i]);
invert.pixels[i] = color(h, 255, 255);
}
} -
void keyPressed() {
inverted = !inverted;
}
void draw() {
image(inverted ? invert : gray,0,0);
fill(0);
ellipse(orig.width/2,orig.height/2,2,2);
}
1