필터 지우기
필터 지우기

how to match an image descriptor to all descriptor in database

조회 수: 2 (최근 30일)
Mirza M
Mirza M 2014년 9월 28일
답변: Nalini Vishnoi 2014년 10월 1일
i want to match my selected image (descriptor) with the database (descriptors) i created. so this is my code to match the selected descriptor with ONLY 1 descriptor in the database :
clc
clear all
close all
[file, path] = uigetfile('*.jpg','Choose Image');
im = imread([path file]);
gray = rgb2gray(im);
[desc] = Descriptor(gray);
dataset1 = load('dataset1.mat');
datasets = dataset1.dataset{1};
Cosine = pdist2(desc, datasets, 'cosine');
CosineSim = [Cosine];
CosIndex = zeros(30,2);
for i = 1:30
[k, ind] = min(Cosine(i,:));
CosIndex(i,1) = k;
CosIndex(i,2) = ind;
Cosine(:,ind) = ones(30,1)*1000;
end
i want the result to be 'CosIndex' for every match with the dataset. in the code above i use 'datasets = dataset1.dataset{1};' just to try one match between two descriptor.
i've tried to use loop and cell 'or 'CosIndex' as many as the dataset but the result is only in the last cell, maybe my loop is error (sorry i already delete the code).
can anyone help me the most efficient way (maybe using cell) to do that?
thank you.

답변 (1개)

Nalini Vishnoi
Nalini Vishnoi 2014년 10월 1일
You can use 'cellfun' to apply a function to each cell in the cell array. Here is some code tailored to your application:
datasets = dataset1.dataset; % reading all the descriptors in a cell array
Cosine = cellfun(@(x) pdist2(desc,x), datasets, 'cosine'); % using cellfun to apply pdist2 to all the cells in the cell array
You can find more documentation of 'cellfun' on the following link: http://www.mathworks.com/help/matlab/ref/cellfun.html

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by