We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone
I need to add a button to a picture, so when i press it, it does edge detection on the image. I tried using convolution matrix but i could not get it to work..! Right now this is what i have for the first two buttons, and they work just fine:
PImage billed;
int aktueltFilter = -1;
void setup() {
billed = loadImage("påfugl.jpg");
size(billed.width, billed.height+50);
}
void draw() {
knap(0,"Stoej");
knap(1,"Pixelering");
knap(2, "EdgeDetection");
if(aktueltFilter == 0){
stoej();
}else if(aktueltFilter == 1){
pixelering();
}else if(aktueltFilter == 2){
EdgeDetection();
}else{
image(billed, 0, 0);
}
}
void mouseClicked() {
if(aktueltFilter == 0){
stoej();
}else if(aktueltFilter == 1){
pixelering();
}else if(aktueltFilter == 2){
EdgeDetection();
}else{
image(billed, 0, 0);
}
}
void knap(int nr, String tekst){
int knapBredde=100;
int knapHoejde=20;
int knapY=billed.height+10;
fill(50);
rect(nr * knapBredde+5, knapY, knapBredde, knapHoejde);
fill(255);
text(tekst, nr * knapBredde+10, knapY+15);
if(mousePressed == true
&& nr * knapBredde < mouseX
&& mouseX < (nr+1) * knapBredde
&& knapY < mouseY
&& mouseY < knapY+knapHoejde)
{
aktueltFilter = nr;
}
}
void stoej(){
for(int y = 0; y < billed.height; y = y + 1){
for(int x = 0; x < billed.width; x = x + 1){
int nyX = x + int(random(10));
color hentFarve = billed.get(nyX, y);
set(x, y, hentFarve);
}
}
}
//Ændring af form
void pixelering(){
int stoerrelse = 10;
for(int y = 0; y < billed.height; y = y + stoerrelse){
for(int x = 0; x < billed.width; x = x + stoerrelse){
fill(billed.get(x, y));
stroke(billed.get(x, y));
rect(x, y, stoerrelse, stoerrelse);
}
}
}
It looks like this:
Would really appreciate any help with adding this feature, since i have no idea what i am doing at this point..
Thanks - Iaften
Answers
please paste the code, not a screenshot of the code.
(after pasting, highlight the code and press ctrl-k to format it for the forum.)
Ok, thanks :)
try again. use a convolution matrix. wikipedia has some example kernels for edge detection.
http://en.wikipedia.org/wiki/Kernel_(image_processing)
post an attempt at least. (and you'll get more replies if the variable names are in english)
hi
i'm struggling with the same project, can anyone help?
continued here:
http://forum.processing.org/two/discussion/5969/edge-detection-and-emboss