File Exchange

image thumbnail

Picture Matching Function

version 1.0 (1.12 KB) by

Matches two pictures given as arguments.

3.46667
15 Ratings

27 Downloads

Updated

No License

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.

Comments and Ratings (20)

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.

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

Josué Dread

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

Ali Tayeh

there is many errors

menna gaber

hi

Indrachapa Bnadara

Good programme

Xz Xz

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

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

austin karathra

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

venkatesh Deva

good

Addison Tsui

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

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.

x zeng

joao Soares:nice work!
Thanks Fahd Ahmad Abbasi also.

WAQAS QURESHI

EXCELLENT BUDDY

loony tones

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!

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.

Janik Zikovsky

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

Hamid Mukhtar

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

ait_picmatch/