Finding Euclidean Distance between two matrices in MATLAB

220 Views Asked by At

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?

0

There are 0 best solutions below