Code covered by the BSD License  

Highlights from
Search duplicate images in sub folders using histogram

image thumbnail
from Search duplicate images in sub folders using histogram by Tharindu Adikari
Finds duplicate images in a folder and in sub-folders using a histogram based method.

add_to_db(file_path)
function b = add_to_db(file_path)
% file_path = 'C:\Users\User\Desktop\New folder\New folder\Image0786.jpg';
global db;
try
    disp([file_path,' ...']);
    h = (imhist(imresize(rgb2gray(imread(file_path)), [200 NaN])));
    
%     subplot(211);bar(h);
    h = mean(vec2mat(h,16),2);
    h = h*100/max(h);
%     subplot(212);bar(h);
%     pause
    
    if (~isfield(db, 'path'))
        i=1;
    else
        i=length(db)+1;
    end
    
    db(i).path = file_path;
    db(i).v = h;
    
catch ME
    %    MATLAB commands     % Catch block
end
b = 1;

Contact us