matlab中的一对多匹配

时间:2015-07-24 08:39:45

标签: matlab matching

我有两个文件夹。我想找到folder1中第一个图像的hierarchyCentroid和文件夹2中的所有图像,然后计算folder1中的图像和folder2中的每个图像之间的dist_1_2,然后找到最小距离并显示它。再次计算folder1中第二个图像的hierarchicalCentroid并找到第二个文件夹中每个元素的距离并计算最小距离等等。我写了一个代码,但它需要一些更改。请帮帮我

Dataset='H:\mainproject\codes\letters_numbers';
Testset = 'H:\mainproject\codes\images\test\kk';
plotFlag = 1;
depth = 6;
DataSet      = cell([], 1);
 for i=1:length(dir(fullfile(Dataset,'*.bmp')))
       % Training set process
       k = dir(fullfile(Dataset,'*.bmp'));
       k = {k(~[k.isdir]).name};
       for j=1:length(k)
           tempImage       = imread(horzcat(Dataset,filesep,k{j}));
          imgInfo         = imfinfo(horzcat(Dataset,filesep,k{j}));
         DataSet{j}  = hierarchicalCentroid(tempImage,depth,plotFlag);
          %Feature = feature_extractor(image(j));
         % DataSet{j}   = imresize(hierarchicalCentroid(tempImage),[width height]);
       end
   end
   TestSet =  cell([], 1);
    for i=1:length(dir(fullfile(Testset,'*.bmp')))
       % Training set process
       k = dir(fullfile(Testset,'*.bmp'));
       k = {k(~[k.isdir]).name};
       for j=1:length(k)
          tempImage       = imread(horzcat(Testset,filesep,k{j}));
          imgInfo         = imfinfo(horzcat(Testset,filesep,k{j}));
        TestSet{j}   = hierarchicalCentroid(tempImage,depth,plotFlag);
       end
    end
  dist_1_2 = sum((DataSet{j} - TestSet{j}) .^ 2);

0 个答案:

没有答案