【问题标题】:texture analysis statistic, feature extraction for detection object in matlab纹理分析统计,matlab中检测对象的特征提取
【发布时间】:2010-06-17 15:55:43
【问题描述】:

我有一个可以从图片中检测对象的项目。它使用反向传播尺度共轭梯度进行训练。我使用了 10 个组件作为输入。 r,g,b,标准差,熵,阈值(Onsu 方法),glcm,包含对比度、同质性、相关性和能量。我手动提取它们。我有 100 个输入。 50是对象,50不是对象。仍然很难手动维护。所以我想使用循环和数组。我使用 2 个文件夹作为文件对象而不是对象。如何提取2个文件夹中的文件? 第一个文件夹:C:\Documents and Settings\User\My Documents\MATLAB\object 第二个文件夹:C:\Documents and Settings\User\My Documents\non object

这是我的编码。我手动将它们写到 100。你能帮我将它们分组并循环吗?


kl=imread('1.jpg');
g=rgb2gray(kl);
rgb=mean(mean(kl));
r1=rgb(:,:,1);
g1=rgb(:,:,2);
b1=rgb(:,:,3);
std1=std2(g);
entropy1=entropy(g);
tres=graythresh(g);
glcm=graycomatrix(g);
F=graycoprops(glcm,{'Contrast','Homogeneity','Correlation','Energy'});

我希望你能给出解决方案。请帮助我。

【问题讨论】:

    标签: matlab computer-vision


    【解决方案1】:

    如果您的所有文件都命名为 1.jpg、2.jpg、...,那么您可以执行以下操作:

    
    for i = 1:50
      fileName = sprintf('%d.jpg', i);
      kl = imread(fileName);
    
      ... the rest of your code...
    
    end
    

    【讨论】:

      【解决方案2】:

      如果除了使用@Dima的解决方案循环遍历每个目录中的图像之外,您还想循环遍历两个目录,您可以执行以下操作:

      dirNames = {'C:\Documents and Settings\User\My Documents\MATLAB\object','C:\Documents and Settings\User\My Documents\non object'};
      
      for directory = dirNames %# loops directly over the elements of the cell array dirNames
         fileList = dir(fullfile(directory{1},'*.jpg')); %# list all jpgs in the directory
         for iFile = 1:length(fileList)
             %# read the ith file
             kl = imread(fullfile(directory{1},fileList(iFile).name));
      
             %# do the calculations here
      
         end
      end
      

      【讨论】:

        猜你喜欢
        • 2015-10-30
        • 1970-01-01
        • 2020-09-01
        • 2012-04-21
        • 2021-01-01
        • 2023-02-03
        • 2013-08-21
        • 1970-01-01
        • 2015-07-04
        相关资源
        最近更新 更多