View Single Post
  #5   Spotlight this post!  
Unread 21-08-2013, 12:43
Maxwell777's Avatar
Maxwell777 Maxwell777 is offline
Is allowed to touch stuff now
AKA: Jackson Gray
FRC #0842 (Falcon Robotics)
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2014
Location: Phoenix, AZ
Posts: 72
Maxwell777 has a spectacular aura aboutMaxwell777 has a spectacular aura aboutMaxwell777 has a spectacular aura about
Re: Need help and suggestions for image comparison method

Quote:
Originally Posted by Greg McKaskle View Post
And what was the problem with dividing by the area? That will give score a range from 0 -- when no pixels match, to 1.0 when all pixels match. That normalizes the score.

I think the bigger problem is that your goal is to determine the shift, and counting matching pixels doesn't always act as a good predictor of shifted distance.

Lets look at two examples.
If the image is simple ... a black background and a smaller white square within it. If I shift the square one pixel to the right, two rows of pixels will contain errors. If I shift it two pixels four rows have errors. It seems to work well. Once the shift amount is greater than the edge size of the square, the score plateaus -- not that helpful in determining shift amount.

In the second image, lets have stripes, like a picket fence. The stripes are two pixels wide with two pixels of black in between. Shift one pixel and half of the rows have errors. Shift two and all rows have errors. Shift three and half have errors again, four and no errors (depends on what enters the frame).

Anyway this difficult problem, and a simple score like you are computing works well in some cases, but less well in others.

After you've completed this approach, perhaps you want to try another based on feature extraction. It could find the largest particle, or the ten largest and compare positions of those. It could identify corners within the image and track those. You may also find it useful to read about Optical Flow algorithms. They are pretty sophisticated to implement, but they are pretty robust.

Greg McKaskle
When you divide the score by the area, I think (as in it's possible there's a bug elsewhere and I lied to you) the program then becomes focused on reducing the area to achieve a better score. I also tried reducing the area's influence (Score = matches / Area/2 ) of the total score, which didn't help.

This program is actually a dumb program, in that it takes every possible shift, and gives it a score, and whichever shift(shiftX, shiftY) has the best score is the shift that it considers to be right. It disregards all scores other than the best one, so it doesn't matter if the score plateaus.

Images the program are working with have almost no pattern whatsoever (it's looking at patches of moss on the bottom of a pool), so I'm not worried about things like you're fence example.

This program is actually an optical flow program, and this was the simplest system I could think of.
Reply With Quote