We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › image warping filter based on grid systems
Page Index Toggle Pages: 1
image warping filter based on grid systems (Read 689 times)
image warping filter based on grid systems
Feb 16th, 2006, 11:57pm
 
Has anyone programmed any image warping filters based on a grids (a grid for the orginal image and a grid for the warped image) in processing? Otherwise if someone could provide some psuedo-code for the basic processes that would be much appreciated. Thanks.
Re: image warping filter based on grid systems
Reply #1 - Feb 17th, 2006, 12:02am
 
These pages by Hugo Elias might help you get started:

http://freespace.virgin.net/hugo.elias/graphics/x_feed1.htm
http://freespace.virgin.net/hugo.elias/graphics/x_warp.htm

Re: image warping filter based on grid systems
Reply #2 - Feb 17th, 2006, 12:14am
 
I've got something that does similar to what you want I think.

The maths-y bit isn't easy to read, but if you split it up into it's components you shoudl be able to see what it's doing.

I think there's possibly some redundancy in the vertex part... the (x+1+y+1)/2.3246 and the like were from before I randomised the phase. I think. It's been a while since I wrote it.

The margin is specific to my needs as well I think, I wante dot make sure that the edge of the image was always onscreen, even if the top-left coordinate was the top left of the screen.

Code:
class wavePlane
{
float phase;
float posx,posy;
float Width,Height;
int div;
float i;
float s;
float depth;
PImage tex;
wavePlane(float _x, float _y,float _w, float _h,int _d,float _i, float _s, float _depth,PImage _tex)
{
div=_d; // number of divisions
tex=_tex; // texture
i=_i; // intensity of the warping, in units
s=_s; // speed of the movement, in terms of how quickly it goes form one extreme to the other.
depth=_depth; // z value
posx=_x; // top left coordinate x
posy=_y; // top left coordinate y
Width=_w; // does what it says...
Height=_h; //
phase=random(0,TWO_PI); // don't want all subdivisions to move in sync.
}

void draw()
{
phase+=s;
float dx=(Width/(float)div)+i;
float dy=(Height/(float)div)+i;
float margin=div/2.0*i;
// stroke(0,255,0);
for(int x=0;x<div;x++)
{
for(int y=0;y<div;y++)
{
beginShape(QUADS);
texture(tex);
vertex(posx-margin+x*dx+i*sin(phase+((x+y)/2.3246)),posy-margin+y*dy+i*cos(phase+((x+y)/1.3246)),depth,x*tex.width/(float)div,y*tex.height/(float)div);
vertex(posx-margin+(x+1)*dx+i*sin(phase+((x+1+y)/2.3246)),posy-margin+y*dy+i*cos(phase+((x+1+y)/1.3246)),depth,(x+1)*tex.width/(float)div,y*tex.height/(float)div);
vertex(posx-margin+(x+1)*dx+i*sin(phase+((x+1+y+1)/2.3246)),posy-margin+(y+1)*dy+i*cos(phase+((x+1+y+1)/1.3246)),depth,(x+1)*tex.width/(float)div,(y+1)*tex.height/(float)div);
vertex(posx-margin+x*dx+i*sin(phase+((x+y+1)/2.3246)),posy-margin+(y+1)*dy+i*cos(phase+((x+y+1)/1.3246)),depth,x*tex.width/(float)div,(y+1)*tex.height/float(div));
endShape();
}
}
noStroke();
}
}
Re: image warping filter based on grid systems
Reply #3 - Feb 17th, 2006, 12:32am
 
Something like this maybe?

http://incubator.quasimondo.com/processing/rubber_screen.php
Page Index Toggle Pages: 1