Help with pixels in my first processing program ever :)
in
Programming Questions
•
7 months ago
Hello all, I have this assignment for my computer class, to make a program in processing, that can, when clicked on a menu, apply different effects to an image.
Right now I am stuck on the last 3 requirements, I need to be able to click somewhere and do the following 3 things (respectively)
Sharpen
Mark edges
Blur
- PImage original; // mit original billede
- PImage temporary; // mit midlertidige billede
- PImage menu; // menu billede
- void setup(){
- size(800,700);
- background(0);
- original = loadImage("Udklip.PNG"); //loader billede
- temporary = createImage(original.width, original.height, RGB); //skaber midlertidigt billede
- menu = loadImage("Menu.png"); //loader menu billede
- image(original,200,0); //originale billede tegnes
- image(menu,0,0); //menuen tegnes
- }
- void draw(){}
- void mousePressed(){
- float r,g,b; //definerer r,g og b som float værdier.
- temporary.loadPixels(); // loader temporarys pixels
- for (int x = 0; x < original.width; x++){
- for (int y = 0; y < original.height; y++){
- r = red(original.pixels[y*temporary.width+x]);
- g = green(original.pixels[y*temporary.width+x]);
- b = blue(original.pixels[y*temporary.width+x]);
- temporary.pixels[y*temporary.width+x] = color(r,0,0);
- if(mouseX<200){ //tjekker først om musen er inden for menuen
- if(15<mouseY && mouseY<70) { temporary.pixels[y*temporary.width+x] = color(r,g,b);} //original
- if(70<mouseY && mouseY<130) { temporary.pixels[y*temporary.width+x] = color(0,0,b);} //blå
- if(130<mouseY && mouseY<190){ temporary.pixels[y*temporary.width+x] = color(r,0,0);} //rød
- if(190<mouseY && mouseY<250){ temporary.pixels[y*temporary.width+x] = color(0,g,0);} //grøn
- if(250<mouseY && mouseY<305){ temporary.pixels[y*temporary.width+x] = color(r+35,g+35,b+35);} //lysere
- if(305<mouseY && mouseY<365){ temporary.pixels[y*temporary.width+x] = color(r-35,g-35,b-35);} //mørkere
- if(365<mouseY && mouseY<420){ temporary.pixels[y*temporary.width+x] = color(r,g,b);} //flipper billedet vertikalt
- if(420<mouseY && mouseY<485){ temporary.pixels[y*temporary.width+x] = color(r,g,b);} //flipper billedet horizontalt
- }
- }
- }
- //gem ændringerne til billedet
- temporary.updatePixels();
- //opdater billedet på skærmen
- background(0);
- image(temporary,200,0);
- image(menu,0,0);
- }
My question is, how do I go about blurring, marking edges, and sharpening my image? I think it has something to do with matrixes or arrays, but I am so confused about it.
The teacher told me it had to do something with the pixels, so I couldnt use premade commands / other ways of manipulating the photo, it had to be interely with the pixels..
Hope there are some friendly souls who will help me :)
1