Advertisement

LLNet模型——利用MATLAB对指定文件格式进行循环遍历的数据准备过程。

阅读量:

1. 背景

达成对特定目录中符合设定格式的文件进行扫描,并获取其存储位置的任务。

2. 代码实现

复制代码
    function filePaths = searchRoot(root_dir, format)
    % Inputs:
    %       root_dir: 需要搜索的文件夹的目录路径
    %       format: 需要过滤识别的文件格式
    % Outputs:
    %       filePaths:
    % Author: HSW
    % Date: 2018-05-05 
    %
    if ~exist('format', 'var')
    format = '.pgm'; 
    end 
    
    searchPaths = search(root_dir, format); 
    
    index = strfind(searchPaths, ','); 
    N = length(index) - 1; 
    filePaths = cell(N, 1); 
    for idx = 1:N
    filePaths{idx} = searchPaths(index(idx) + 1 : index(idx + 1) - 1); 
    end 

全部评论 (0)

还没有任何评论哟~