MATLAB批量读取文件夹中文件,处理后放在新的文件夹中
来源:互联网 发布:nginx 外网代理 编辑:程序博客网 时间:2024/04/30 13:46
clc;clear all;close all
%%
% currPath = fileparts(mfilename('fullpath'));% 获得当前路径
currPath='C:\MATLAB\R2007b\toolbox\images\imdemos\html';
imagetype=char('.png');
nameall=strcat('*',imagetype);
A = dir(fullfile(currPath,nameall));
% 读取后A的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not
% 未知
A = struct2cell(A);
num = size(A);
for k =0:num(2)-1
x(k+1) = A(5*k+1);% 找出name序列,x存储内容图片名字
end
%% 新建路径
newdir=char('ning_result');
mkdir(newdir)
%% 读取得到mat文件
for k = 1:num(2)
newpath = strcat(currPath,'\',x(k));
temp = strcat(newpath,imagetype);
image_name=char(x(k))
im_temp=imread(char(newpath));
newname=char(strcat(newdir,'\',image_name))
% imwrite(im_temp,'dirName\图象.jpg','jpg');
imwrite(im_temp,sprintf('%s%d%s',newname,k,imagetype));
% imwrite(im_temp,[newdir,sprintf('%s%d%s','new',k,imagetype)]);
end
%%
% currPath = fileparts(mfilename('fullpath'));% 获得当前路径
currPath='C:\MATLAB\R2007b\toolbox\images\imdemos\html';
imagetype=char('.png');
nameall=strcat('*',imagetype);
A = dir(fullfile(currPath,nameall));
% 读取后A的格式为
% name -- filename
% date -- modification date
% bytes -- number of bytes allocated to the file
% isdir -- 1 if name is a directory and 0 if not
% 未知
A = struct2cell(A);
num = size(A);
for k =0:num(2)-1
x(k+1) = A(5*k+1);% 找出name序列,x存储内容图片名字
end
%% 新建路径
newdir=char('ning_result');
mkdir(newdir)
%% 读取得到mat文件
for k = 1:num(2)
newpath = strcat(currPath,'\',x(k));
temp = strcat(newpath,imagetype);
image_name=char(x(k))
im_temp=imread(char(newpath));
newname=char(strcat(newdir,'\',image_name))
% imwrite(im_temp,'dirName\图象.jpg','jpg');
imwrite(im_temp,sprintf('%s%d%s',newname,k,imagetype));
% imwrite(im_temp,[newdir,sprintf('%s%d%s','new',k,imagetype)]);
end
- MATLAB批量读取文件夹中文件,处理后放在新的文件夹中
- matlab 批量读取文件夹中的图片、处理后、保存于另一文件夹
- Matlab中从文件夹中批量读取文件的做法
- Bash中批量替换文件夹中文件的字符串
- MATLAB中从文件夹批量读取图片文件的方法
- MATLAB批量读取文件夹的图片
- C++文件夹中文件的读取
- Matlab批量读取文件夹文件
- 读取文件夹中文件路径
- matlab读取文件夹中的所有内容(用于批量处理)
- VS2010MFC批量读取文件夹中的图片,处理后批量存入另一个文件夹
- Matlab批量读取一个文件夹里的文件
- Matlab从其他文件夹批量读取存储图片的心得体会
- MATLAB批量读取一个文件夹里的图像
- Matlab中的.m文件必须放在安装目录下的work文件夹中才能打开
- MATLAB读取文件夹中的批量图像
- c++将一个文件夹下的所有文件读取出来放在一个文件中
- 读取文件夹中文件所有文件名
- IOS CoreData 多表查询demo解析(一)--建表
- 杭电水题之1713
- 电脑硬件名词基础扫盲
- linux下c++的编译器g++的基本使用
- poj Cows 树状数组
- MATLAB批量读取文件夹中文件,处理后放在新的文件夹中
- Jade报错:Invalid indentation,you can use tabs or spaces but not both问题
- IOS CoreData 多表查询demo解析(二)--插入测试数据
- log4j使用DailyRollingFileAppender
- Linux-3.2.0.24中内核的Netlink测试使用
- Android 4.0新增Space及GridLayout初谈
- IOS CoreData 多表查询demo解析(三)--查询
- 网站优化的idea
- 【DFS】hdu 1426 Sudoku Killer