0

I am making a Content Based Image Retrieval system for university database. I am using colored features for matching similarity between images. Resolution of my images are 648 * 424 px. Basically what I am doing is:

  1. Getting colored histogram of 8 * 8 px blocks of image and concatenating all of these in a single matrix. For this purpose I am using MATLAB function blockproc and code is shown below:

    % Reading two images from Database
    A = imread('bonfire/1.jpg');
    B = imread('bonfire/2.jpg');
    
    % Using blockproc to get feature vector for both images
    C = blockproc(A ,[8, 8], @localHistogram);
    D = blockproc(B, [8, 8], @localHistogram);
    

    While the function localHistogram is:

    function y = localHistogram(block_struct)
    
        % Separating Red, Green and Blue planes
        redPlane    = block_struct.data(:, :, 1);
        greenPlane  = block_struct.data(:, :, 2);
        bluePlane   = block_struct.data(:, :, 3);
    
        % Obtaining histogram for all 3 planes with number of bins = 50
        [pixelCountR, grayLevelsR] = imhist(redPlane, 50);
        [pixelCountG, grayLevelsG] = imhist(greenPlane, 50);
        [pixelCountB, grayLevelsB] = imhist(bluePlane, 50);
    
        % Concatenating three histograms of respective planes
        y = cat(2,pixelCountB, pixelCountG, pixelCountR);
    
    end
    
  2. Now I want to find the similarity between the two images by comparing there feature vectors C and D using Euclidean Distance. The dimensions of C and D are 2650 * 243.

What will be the best method to do this with maximum efficiency?

thegamerpark
  • 29
  • 1
  • 1
  • 4
  • 1
    `EuclidDist = sum((D-C).^2)`? – Wolfie Mar 01 '17 at 15:14
  • The duplicate should give you what you want. Place your query histograms in one matrix and place the histograms of your database in another matrix. Each histogram is placed row-wise. The duplicate will give you the pairwise distance matrix where you simply have to search for the minimum index of each row that indicates the best match per query. Note that computing the Euclidean distance and Euclidean distance squared when finding the best matching image is the same, so you can take advantage of finding the squared Euclidean distance which is what the duplicate finds. – rayryeng Mar 01 '17 at 15:15
  • Thanks. I will take a look at the duplicate. – thegamerpark Mar 01 '17 at 15:19

0 Answers0