We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys,
For my studies I have to do some filters in Processing, but I have to do it without using " filter() "... I must use a table such as this one :
PImage raptorJesus; color[][]tableaucouleurs = new color [197][255]; color[][]gris=new color[197][255]; int clic=0;
void setup() { background(255); size(600, 800); raptorJesus=loadImage("raptor jesus.jpg"); image(raptorJesus, 200, 50);
for (int i=0; i<197; i++) { for (int j=0; j<255; j++) { tableaucouleurs[i][j]=get(i+200, j+50); } } }
void draw() { if (clic==0) { fill(0, 255, 0); rect(260, 500, 100, 50); textSize(24); fill(0); text("ACTION", 265, 530); } if (clic==1) { suppression(); clic=2; } if (clic==2) { image(raptorJesus, 200, 50); for (int i=0; i<197; i++) { for (int j=0; j<255; j++) { set(i+200,j+305,gris[i][j]); noLoop(); } } } }
void mousePressed(){ if((mouseX>250)&&(mouseX<350)&&(mouseY>500)&&(mouseY<550)){ clic=1; background(255); } }
void suppression(){ for (int i=0; i<197; i++) { for (int j=0; j<255; j++) { float v= green(tableaucouleurs[i][j]); float b= blue(tableaucouleurs[i][j]); float r= red(tableaucouleurs[i][j]); float g=(v+b+r)/3; gris[i][j]=color(g); } } }
This one is a kind of Black and White filter, I have some others which enable me to invert colors or remove Red, Green or Blue ones. But I was wondering how to make manually a THRESHOLD, POSTERIZE or even BLUR filter. So if you have any idea how I can make it ^^
Answers
Format your code above. Edit your post, select code and hit ctrl+o.
Have you checked the example files that comes with Processing? There are some interesting demos, like an edge detection filter. You can check the Capture folder under External Libraries/Video which provide pixel manipulation on data streamed from a capture device aka. video camera. You can check their algorithm they used.
In the forum, you can always search for posts associated with loadPixels[] and you will find previous posts with image/pixel manipulation that you can find of interest.
Kf
See this:
https://forum.processing.org/two/discussion/13525/convolution#latest
Buon Natale