Go to Post How FIRST is helping: teaching me just how much I can achieve in 6 weeks. - Otaku [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 20-08-2013, 23:59
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
Question Need help and suggestions for image comparison method

Things to note:
I am using C++, Qt, and OpenCV.

Background info:
I am trying to create a program (actually a method) in C++ that takes two (filtered to two color black & white) images from a moving robot, one within X amount of time of the other, then trys to find the amount of shift between each frame. It does this by overlaying the second picture ontop of the first, in every possible placement, and comparing the overlapping area, pixel per pixel.

I've gotten all of the bugs out (to the extent of my knowledge), with the exception of one. There is a method that takes two images, one from the overlapping area of each frame, counts each matching pixel, and returns a "score" of how similar the two images that were passed in. My issue with this is the "score" returned. This score only returns the number of matching pixels. If I were to give it larger images, it would return a larger score than if I gave it smaller ones, even if the smaller ones were more similar. I've already tried dividing the score by the area of the images.

The program does that for many different images to figure out which is the best match, which is dictated by the "score".

I was wondering what the best way to calculate the "score" is, that would always give the pair of images with the most in common the best score, regardless of size or shape.

Here is the troublesome code:

double ImgCompare (Mat Img1, Mat Img2, int ImgWidth, int ImgHeight) { //both images are the same diamentions

double Score = 0;

double ImgArea = ImgWidth * ImgHeight;

for (int Y = -1; Y < abs(ImgHeight-2); Y=Y) {

for (int X = -1; X < abs(ImgWidth-2); X=X) {

if (Img1.at<double>(X,Y) == Img2.at<double>(X,Y) ) {

Score++;

}

X++;

}

Y++;

}

//printf("Score = %f\n", Score);
return(Score);

}


Sorry for the lack of indents

Would anyone like the code for the rest?

Last edited by Maxwell777 : 21-08-2013 at 12:45.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi