Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Image comparison
Date: Tue, 27 Jan 2009 15:14:02 +0000 (UTC)
Organization: Queen's University
Lines: 15
Message-ID: <gln8bq$cvp$1@fred.mathworks.com>
References: <6f1ec872-1f6b-487e-9a66-38d8d0679041@p23g2000prp.googlegroups.com> <lkmfl.2$8O.0@newsfe06.iad> <d8b82541-f147-4e5e-8529-11658b87e993@q30g2000prq.googlegroups.com> <gln7ab$ou$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1233069242 13305 172.30.248.37 (27 Jan 2009 15:14:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Jan 2009 15:14:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 943450
Xref: news.mathworks.com comp.soft-sys.matlab:514256


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