Thread Subject: Image comparison

Subject: Image comparison

From: Niall 84

Date: 26 Jan, 2009 16:36:49

Message: 1 of 8

Hi all,

I am trying to set up a database of images that can be used to compare
to a current image (So if the current image is equal, or almost equal
to the one being compared it'll give a match)

However to start this project off I want to just compare 2 images
using Matlab to see how the process works.

Does anyone know how I might compare say imaeg1.jpg and image2.jpg to
see how closely related to each other they are? So basically if I was
to compare image1.jpg and image1.jpg the relationship should be 100%,
but comparing 2 different images might give me quite a close
relationship.

I hope that makes some sense!!!

Thanks,

Niall.

Subject: Image comparison

From: Walter Roberson

Date: 26 Jan, 2009 17:23:55

Message: 2 of 8

Niall 84 wrote:

> I am trying to set up a database of images that can be used to compare
> to a current image (So if the current image is equal, or almost equal
> to the one being compared it'll give a match)

First you have to start by defining what it means for one image to
be "almost equal" to another. Is B equal to C if C is B rotated 90 degrees?
If C is B flipped on its horizontal axis? If C is B rotated 17 degrees
around a point that is -not- its center? If B and C are two different
pictures of the same scene but due to natural muscle motion, they are
not of -exactly- the same scene coverage? If C is the same scene as B
but C is overexposed by 1 f-stop? If C is the same scene as B except
the green light in the picture turned red? If C is the same scene as B
but taken a little later in the day when the lighting was a bit different?
If C is the same scene as B but taken at a different resolution? Taken
with a different camera? If C is an image of the same person as in B
except in C, they put on sunglasses? Put on a false moustache?
Does this program need to be able to solve those "which of these
drawings is different from the others" childrens' puzzles?

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: Image comparison

From: Niall 84

Date: 27 Jan, 2009 11:47:43

Message: 3 of 8

Ok,

Apologies for the lack of clarity.

Basically I am trying to develop a new algorithm that can be used for
the RoboCup soccer competition. The basics of it is that there will be
a database of possible images that the robot could see, and I want to
match what the robot actually sees with its match in the database.
(The database images will have information attached to it that will
tell the Robot where it is located on the pitch)

However, to take absolutely every possibility would mean millions of
images, but I'm sure it is possible for images that are very similar,
but may have been taken at a slightly different angle, or taken from
very close to, but not exactly the same location, to be matched. But I
don't know how I might go about doing this.

Hope that makes more sense.

Subject: Image comparison

From: Steven Lord

Date: 27 Jan, 2009 14:56:11

Message: 4 of 8


"Niall 84" <niall_heavey@yahoo.com> wrote in message
news:d8b82541-f147-4e5e-8529-11658b87e993@q30g2000prq.googlegroups.com...
> Ok,
>
> Apologies for the lack of clarity.
>
> Basically I am trying to develop a new algorithm that can be used for
> the RoboCup soccer competition. The basics of it is that there will be
> a database of possible images that the robot could see, and I want to
> match what the robot actually sees with its match in the database.
> (The database images will have information attached to it that will
> tell the Robot where it is located on the pitch)
>
> However, to take absolutely every possibility would mean millions of
> images, but I'm sure it is possible for images that are very similar,
> but may have been taken at a slightly different angle, or taken from
> very close to, but not exactly the same location, to be matched. But I
> don't know how I might go about doing this.
>
> Hope that makes more sense.

It sounds like a combination of image registration and optimization -- find
the stored image that minimizes the "amount of transformation" necessary to
make it agree with what the robot sees.

Two of the problems I can see:

1) defining how to quantify the "amount of transformation" (if the image
needs to be rotated 5 degrees counterclockwise to match a stored view, is
that a greater amount of transformation or a lesser amount of transformation
than a translation of 5 pixels? Which one is "closer"?)

2) dealing with "stuff" (other robots and the ball, most likely) that are in
the picture that the robot sees right now, but are not in the stored
database. The "stuff" could block the robot's line of sight, concealing the
features that the robot would need to match what it sees with a stored
image.

 I'm sure there are others.

I'm not sure CSSM is the right newsgroup to be able to help you with either
of those problems I described above. You may have better luck asking in an
image processing newsgroup, like sci.image.processing, to determine if
there's a standard algorithm or approach you should use to handle either of
these problems. Then, if you need help implementing that algorithm in
MATLAB, ask those questions here in CSSM.

--
Steve Lord
slord@mathworks.com

Subject: Image comparison

From: Pete

Date: 27 Jan, 2009 15:14:02

Message: 5 of 8

Hi,

Your original post reminded me of something I read in 'A primer on wavelets and their scientific applications' by James S Walker (2nd edition, pp 141-144). He talks about checking whether an image is similar to other images in a database. Basically, you need some sort of error measure. So if im1 is your database image and im2 is the one you want to check, you could use:

D = sqrt(sum((im2(:) - im1(:)).^2)) / sqrt(sum(im1(:).^2));

If D is small, then im1 and im2 are similar. You might need to think about what to do with the different channels if you've got colour images. Perhaps you can use the green of the pitch to help get a horizon line, and the angle of that could be useful.

The wavelet transform comes in because it will effectively break up an original image into smaller subimages, each encoding a different level of detail. The smaller images can be compared much more quickly, and are less affected by noise, so you calculate D for the small image approximations produced by the wavelet transform first. You then only need to do more detailed similarity tests if the fast test produces a good match.

If you haven't used wavelets before, check out the Haar transform - it's the easiest one, and can be implemented in a few lines of MATLAB code. Gaussian pyramids are somewhat related, so you could look at the impyramid function in the Image Processing Toolbox. normxcorr2 might also be of interest.

That said, I suspect this approach will be too basic to get you very far unless the image comparison part plays a fairly minor role, you can be pretty confident about things like lighting conditions and you have a way to deal with other robots getting into your robot's field of view. If you need something really advanced, it might be worth trawling through the face recognition literature.

Pete

Subject: Image comparison

From: ImageAnalyst

Date: 27 Jan, 2009 16:34:17

Message: 6 of 8

Niall:
There's tons and tons of research on this subject. It's usually
called "image registration." MATLAB even has a help entry for this,
if you have the image processing toolbox. This usually refers to the
images being the same size and largely overlapped (like your
situation) and rotated, warped, etc. There's a related field called
"pattern matching" where the "pattern" image is usually just a small
sub-part of the larger image (and of course it could be translated,
rotated, warped, or even partially occluded in the main image). This
is big in the defense field for obvious reasons. So, given that
there's a bazillion methods for doing it, and more coming out every
month, I suggest that you first do a literature search to find
something similar to your situation and that might meet your needs.
Or, for starters, you could check out the stuff MATLAB supplies in the
image processing toolkit.
Regards,
ImageAnalyst

Subject: Image comparison

From: Niall 84

Date: 27 Jan, 2009 16:52:23

Message: 7 of 8

Thank you both for your help.

In relation to the issues that you brought up Steve, I am planning on
running morphology and the Hough Transform on the image 1st, which
should give me a new image with just the white lines, and should
ignore the robot and ball............hopefully anyway!!!

And the formula that you gave me Pete is very useful. Hopefully I can
use that to my advantage!!!

Thanks very much.

Niall.

Subject: Image comparison

From: Matlab User

Date: 31 May, 2009 23:06:01

Message: 8 of 8



ICSP2008 Proceedings

Image Change Detection using Copulas, ZENG Xuexing and Tariq S DURRANI


might be worth looking...

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com