MATLAB Answers

hp
0

how to find the euclidean distance between two images

Asked by hp
on 7 Jun 2017
Latest activity Answered by hp
on 15 May 2018
how to find the euclidean distance between two images... and how to compare query image with all the images in the folder. and if there is a statistical data like mean, mode, standard deviation(more than one value) how to collect and where to store, in such a way that it can useful for comparison.

  0 Comments

Sign in to comment.

4 Answers

Answer by Jan
on 7 Jun 2017
Edited by Jan
on 21 Oct 2017

  • Euclidean distance between two images:
Dist = sqrt(sum((image1(:) - image2(:)) .^ 2)); % [TYPO fixed, thanks Sean]
This works if the images have the same size. If now, scale one by linear of Lanczos interpolation.
  • compare query image with all the images in the folder
FileList = dir(fullfile(Folder, '*.jpg'));
Result = cell(1, numel(FileList));
for iFile = 1:numel(FileList)
File = fullfile(Folder, FileList(iFile).name);
Img = imread(File);
... Now compare the current image with the one to be checked
Result{iFile} = ...
end
  • is there is a statistical data like mean, mode, standard deviation(more than one value) how to collect and where to store, in such a way that it can useful for comparison.
This is the wrong direction. You have to determinem, what you are looking for. The forum cannot guess, what is useful for you. Perhaps you want to recognize some vegetables, or intergalactic gas clouds, perhaps colored cows or predict, what will be the fashion for umbrellas in the next year by scanning persons in Paris from a near earth orbit. What are you looking for?

  5 Comments

Hi, if i have 3d image (rows, columns & pixel values), how can i calculate the euclidean distance between rows of image if i assume it as vectors, or c between columns if i assume it as vectors? thanx
So, is it a regular RGB image? Or do you have an N by 5 2-D matrix of numbers with each row being [x, y, redValue, greenValue, blueValue]? Why do you want this anyway? What do you think it will do for you?
rowRGB = reshape(RGBImage, size(RGBImage,1), []);
dist_between_rows = pdist(rowRGB);

Sign in to comment.


Answer by KSSV
on 7 Jun 2017

You can compute standard statistics of an image using the mean2, std2, and corr2 functions. mean2 and std2 compute the mean and standard deviation of the elements of a matrix. corr2 computes the correlation coefficient between two matrices of the same size.

  4 Comments

Show 1 older comment
images = dir('*.jpg') ; % your extenion
N = length(images) ; % total images
iwant = cell(N,1) ;
for i = 1:N % loo for each image
% do waht you want, let iwant be std2
iwant{i} = std2(images(i).name)
end
std2(images(i).name)
The standard deviation over the characters of the file name?
I have below code ...
using below code , query an image... and it should return set of similar images as of query image (i am having matlab7 version)
how to do it...
function colorMoments = colorMoments(image)
% input: image to be analyzed and extract 2 first moments from each R,G,B
% output: 1x6 vector containing the 2 first color momenst from each R,G,B
% channel
[filename,pathname]=uigetfile({'*.jpg';'*.png';'*.tif';'*.bmp'},'File Selector');
image=imread([pathname,filesep,filename]);
% extract color channels
R = double(image(:, :, 1));
G = double(image(:, :, 2));
B = double(image(:, :, 3));
% compute 2 first color moments from each channel
meanR = mean( R(:) );
stdR = std( R(:) );
meanG = mean( G(:) );
stdG = std( G(:) );
meanB = mean( B(:) );
stdB = std( B(:) );
% construct output vector
colorMoments = zeros(1, 6);
colorMoments(1, :) = [meanR stdR meanG stdG meanB stdB];
% clear workspace
clear('R', 'G', 'B', 'meanR', 'stdR', 'meanG', 'stdG', 'meanB', 'stdB');
end

Sign in to comment.


Answer by Biruk Fikadu on 14 May 2018

In the following arrangement of pixels, what’s the value of the distance between the circled two points using the three distance measurements?

  0 Comments

Sign in to comment.


Answer by hp
on 15 May 2018

how to predict a query image's class using naivebayes classifier? plz help

  0 Comments

Sign in to comment.