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.
Page Index Toggle Pages: 1
Mask with Jmyron ? :( (Read 517 times)
Mask with Jmyron ? :(
Feb 4th, 2008, 3:36pm
 
hi people,  

i am trying to mask image by using Jmyron. it is working but too slow how can I solve it ? any suggestions?


//////////
import JMyron.*;
JMyron m;
PImage[] frames;
PImage img,bg;
float[][] mask;
float decay = 0.016;
//--------------------
void setup(){
 size(320,240);
 m = new JMyron();
 m.start(width,height);
 m.findGlobs(1);
 m.adaptivity(50.0);
 frameRate(50);
 frames = new PImage[2];
 frames[0] = loadImage("car1.jpg");
 frames[1] = loadImage("car2.jpg");
 mask = new float[width][height];
}
//--------------------
void draw(){
 loadPixels();
 m.update();
 m.imageCopy(pixels);
 int[][] b = m.globBoxes();
 for(int i=0 ; i<width ; i++){
   for(int j=0 ; j<height ; j++){
for(int c=0 ; c<b.length ; c++){
float brush = brushPower(b[c][0] , b[c][1] ,i,j);
mask[i][j] = constrain( mask[i][j] - decay + brush, 0 , 1 );
//pixels[i+j*width] = getPixel(i,j);
    }
   }
   }
updatePixels();
}
//--------------------
float brushPower(int ox, int oy,int x, int y){
 float d = dist(ox,oy,x,y);
 return 0.09*exp(-d*d*0.00025);
}
//--------------------
color getPixel(int i, int j){
 float amount = mask[i][j];
 int index = i+j*width;
 if(amount<0.3333)
   return lerpColor(frames[0].pixels[index],frames[1].pixels[index],3*amount);
 else  
   return lerpColor(frames[1].pixels[index],frames[1].pixels[index],2*amount-1);
}
Re: Mask with Jmyron ? :(
Reply #1 - Feb 5th, 2008, 8:48am
 
any idea?
Re: Mask with Jmyron ? :(
Reply #2 - Feb 5th, 2008, 10:44am
 
The moderators on this board take offense at posting multiple threads with the same topic. They have to remove the posts manually.

You could try searching for other computer vision topics on the board which deal with hacks to speed up image scanning if you're too impatient to wait for an answer. There's quite a few if you look hard enough. Thankfully the moderators have removed all of the double posted topics that would impede such a search. Otherwise I'm afraid you'll have to wait until someone with experience in your field comes along.
Re: Mask with Jmyron ? :(
Reply #3 - Feb 5th, 2008, 11:02am
 
sorry, ur right i am not patient bcoz i might be crazy. i have tried many things. Sad
Page Index Toggle Pages: 1