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 & HelpSyntax Questions › Comparing / Mapping 2 images (JPG)
Page Index Toggle Pages: 1
Comparing / Mapping 2 images (JPG) (Read 263 times)
Comparing / Mapping 2 images (JPG)
Jul 29th, 2008, 7:33pm
 
Hi,
i´m new on Processing, Im a Brazilian developer and I´m studing a lot.


I have to do something like that:
http://www.flickr.com/photos/28856217@N04/2714505842/


We have a camera that take pictures of screw production and we wana count the helical groove and measure the dimensions.

I just wanna a way to go.

Someone have an idea ?
Some library or class ?

Tkx very much !



Rainer
Re: Comparing / Mapping 2 images (JPG)
Reply #1 - Jul 30th, 2008, 4:39am
 
Here's a start: it looks at a horizontal row of pixels (defined by mouseY), and finds edges (defined as an alternation between a light pixel and a dark, so make sure the image is high contrast).
Dan

===========================
PImage screwImage;
void setup(){
 size(640,480);
 screwImage=loadImage("screwphoto.jpg");
 frameRate(10);
}
void draw(){
 image(screwImage,0,0);
 int ridgeYPos = mouseY;//y position of horizontal line that crosses the threads
 int threadCount=0;
 float currBrightness, lastBrightness=0;
  stroke(0,255,0);
 for(int i=0;i<screwImage.width;i++){//for each pixel of the image's width
   currBrightness=brightness(screwImage.pixels[ridgeYPos*screwImage.width+i]);//get the brigtness of current pixel
   if(currBrightness<128&&lastBrightness>128){//detect edge between light and dark: if current pixel is dark and previous was light
     threadCount++;
     line(i,ridgeYPos-5,i,ridgeYPos+5);//draw little green line at edge
   }
   lastBrightness=currBrightness;
 }
 stroke(255,0,0);
 line(0,ridgeYPos,screwImage.width,ridgeYPos);//red line across
 print("\nY position:"+ridgeYPos+" threadCount "+threadCount);
}
Re: Comparing / Mapping 2 images (JPG)
Reply #2 - Jul 30th, 2008, 2:42pm
 
Thank you very very much my friend danI !
Is a greeeeat start.
So now i will go on from here and wait from my reply to show the final results.

Rainer from Brazil !
Page Index Toggle Pages: 1