Hello Mat

 找回密码
 立即注册
查看: 5393|回复: 0

遍历文件夹下的全部图像文件

[复制链接]

84

主题

115

帖子

731

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
1467
发表于 2019-5-14 23:24:41 | 显示全部楼层 |阅读模式
遍历文件夹下的全部图像文件:并将其切分,写入到另一个文件夹
  1. clc,clear, close all
  2. warning off
  3. FilePath='./train';
  4. fileList = dir(FilePath);
  5. savePath='./train2';
  6. for i=1:length(fileList)
  7.     if strcmp(fileList(i).name,'.')==1||strcmp(fileList(i).name,'..')==1
  8.         continue;
  9.     else
  10.         fileList(i).name;
  11.         img = imread([FilePath,'/',fileList(i).name]);
  12.         % Crop Parts
  13.         
  14.         imwrite(img, [savePath,'/',fileList(i).name])
  15.     end
  16. end
复制代码












回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-20 04:28 , Processed in 0.209757 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表