Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import controlP5.*;
- PImage img;
- ControlP5 debugUI;
- int brightness1 = 255;
- int saturation1= 255;
- int hue1= 255;
- void setup()
- {
- size(1000, 750); //set window size to same resolution as image
- colorMode(HSB, 255, 255, 255);
- img = loadImage( "GracefieldMorning.jpg" ); //loading image into memory (RAM) - no GPU acceleration here
- //setting up our slider and adding the "brightness" so it knows that the variable it controls
- debugUI = new ControlP5(this);
- debugUI.addKnob("brightness1")
- .setRadius(30)
- .setPosition( 10, 10 )
- .setRange( 0 , 510 )
- .setValue(255);
- debugUI.addKnob("saturation1")
- .setRadius(30)
- .setPosition( 80, 10 )
- .setRange( 0, 510 )
- .setValue(255);
- debugUI.addKnob("hue1")
- .setRadius(30)
- .setPosition( 150, 10 )
- .setRange( 0, 20 );
- }
- void draw()
- {
- //MAke a copy so we can keep original intact
- PImage imgcopy = img.get();
- imgcopy.loadPixels();
- float brightRatio = (float)brightness1 / 255.0f;
- float satRatio = (float)saturation1/ 255.0f;
- float hueRatio = (float)hue1;//255.0;
- int numPixels = imgcopy.pixels.length;
- for(int i = 0; i < numPixels; i++)
- {
- color prevCol = imgcopy.pixels[i];
- color newCol = color( hue(prevCol) * hueRatio, saturation(prevCol) * satRatio, brightness(prevCol) * brightRatio);
- imgcopy.pixels[i] = newCol;
- }
- imgcopy.updatePixels();
- image(imgcopy, 0, 0, width, height);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement