### Highlights from Picture Matching Function

3.35714
3.4 | 14 ratings Rate this file 2 Downloads (last 30 days) File Size: 1.12 KB File ID: #5456 Version: 1.0

# Picture Matching Function

### Fahd Ahmad Abbasi (view profile)

11 Jul 2004 (Updated )

Matches two pictures given as arguments.

File Information
Description

The function takes two images as argument and using edge detection checks whether they are the same or not...a cool and simple code which can be used in security systems. The level at which the two pictures should be matched can be controlled.

Required Products Image Processing Toolbox
MATLAB release MATLAB 6.5 (R13)
28 Mar 2014 NICK

### NICK (view profile)

@joao Soares : I tried ur code but m getting the foll. error-
Error using ait_picmatch1 (line 3)
Not enough input arguments.

Can any1 plz help me with this.

Comment only
12 Nov 2012 piyush kant

### piyush kant (view profile)

What so ever about the size.
It gives a brief idea about matching algorithm.
good work.

Sorry, I'm new at matching images and using Matlab, can you helpme telling me how to show the matched image??

Comment only
22 Nov 2011 Ali Tayeh

### Ali Tayeh (view profile)

there is many errors

Comment only
31 May 2008 menna gaber

hi

Comment only

Good programme

19 Jan 2008 Xz Xz

austin karathra, yes it's ravings of a madman.Very simple realization, work only with identical picrures!!!

22 Dec 2007 z lijie

Recently ,I'm looking for the code almost everywhere and finally I'm very lucky to find it here.thankyou!Fahd Ahmad Abbasi

11 Dec 2007 austin karathra

This is not working and again this algorithm will not work if the images are shifted by a pixel.
need some modifications

17 Jul 2007 venkatesh Deva

good

Use the im2bw() function with a threshold in the code would provide a more clear comparison of the images.

14 Dec 2006 Noman Shaukat

A bit of noise destroys the whole process .
Even does not works for a threshold percentage of 40% and applications of filters. (I am working on TV captures). A preferred method would be to go for corners instead of edges. and do feature correspondance or Instead of relying on edges or corners go for cross correlation.
Process would be expensive, but the desired match quality would be there.

27 Sep 2006 x zeng

joao Soares:nice work!

Comment only
28 Aug 2006 WAQAS QURESHI

EXCELLENT BUDDY

01 May 2006 loony tones
08 Jan 2006 joao Soares

The code is terribly inneficient, only works if the images are taken under the same conditions! try to compare 2 diferent pictures taken to the same object, the ratio will be very low... I´ve improved you code :

function ait_picmatch(pic1,pic2)

[x1,y1,z1] = size(pic1);
if(z1==1)
;
else
pic1 = rgb2gray(pic1);
end

[x2,y2,z2] = size(pic2);
if(z2==1)
;
else
pic2 = rgb2gray(pic2);
end

%applying edge detection on first picture
%so that we obtain white and black points and edges of the objects present
%in the picture.

edge_det_pic1 = edge(pic1,'prewitt');

%%applying edge detection on second picture
%so that we obtain white and black points and edges of the objects present
%in the picture.

edge_det_pic2 = edge(pic2,'prewitt');

%definition of different variables to be used in the code below

%output variable if pictures have been matched.
OUTPUT_MESSAGE = ' Hence the pictures have been matched, SAME PICTURES ';

%output variable if objects in the whole picture have not been matched.
OUTPUT_MESSAGE2 = ' Hence the pictures have not been matched, DIFFERENT PICTURES ';

%initialization of different variables used
matched_data = 0;
white_points = 0;
black_points = 0;
x=0;
y=0;
l=0;
m=0;

%for loop used for detecting black and white points in the picture.
for a = 1:1:x1
for b = 1:1:y1
if(edge_det_pic1(a,b)==1)
white_points = white_points+1;
else
black_points = black_points+1;
end
end
end

%for loop comparing the white (edge points) in the two pictures
for i = 1:1:x1
for j = 1:1:y1
if(edge_det_pic1(i,j)==1)&(edge_det_pic2(i,j)==1)
matched_data = matched_data+1;
else
;
end
end
end

%calculating percentage matching.
total_data = white_points;
total_matched_percentage = (matched_data/total_data)*100;

%outputting the result of the system.
if(total_matched_percentage >= 90) %can add flexability at this point by reducing the amount of matching.

total_matched_percentage
OUTPUT_MESSAGE
else

total_matched_percentage
OUTPUT_MESSAGE2
end

This code only works for images with the same size, but the size is now variable!

12 Sep 2005 Bob Floogerman

Very simple code, easy to use AND scale- could easily be modified for images of any size, and it's easy to adjust the tolerance (percentage) of comparison. Too bad this is dependent on matlab, and not a library for PHP, ASP, or some other unversal scripting language.

14 Apr 2005 Janik Zikovsky

Will not handle sizes other than 256x256, inefficient unvectorized code.

17 Dec 2004 Hamid Mukhtar