MATLIB 多个子文件夹批量创造测试文件
来源:互联网 发布:hadoop数据目录配置 编辑:程序博客网 时间:2024/04/30 14:03
maindir='Z:\\ ';writepath='Z:\\ ';%fp = fopen(maindir,'wt');subdir =dir( maindir ); % 先确定子文件夹for i = 3 : length( subdir ) if( isequal( subdir( i ).name, '.' ) || ... isequal( subdir( i ).name, '..' ) || ... ~subdir( i ).isdir ) % 如果不是目录跳过 continue; end subdirpath = fullfile( maindir, subdir( i ).name, '*.bmp' ); images = dir( subdirpath ); % 在这个子文件夹下找后缀为jpg的文件 % 遍历每张图片 for j = 3 :length( images ) imagepath = fullfile( maindir, subdir( i ).name, images( j ).name ); img = imread( imagepath ); subplot(3,3,1) imshow(img) title('original'); b=imrotate(img,3,'nearest'); b = imresize(b, [32 18]); subplot(3,3,2) imshow(b) title('rotate 5'); c=imrotate(img,-3,'nearest'); c = imresize(c, [32 18]); subplot(3,3,3) imshow(c) title('rotate -5'); SE1=strel('ball',2,2); erode=imerode(c,SE1,'same'); %erode erode = imresize(erode, [32 18]); subplot(3,3,4) imshow(erode); title('erode'); SE2 = strel('disk', 1); dilate=imdilate(c,SE2,'same'); %dilate dilate = imresize(dilate, [32 18]); subplot(3,3,5) imshow(dilate) title('dilate'); V=0.008; Noisy=imnoise(c,'gaussian',0,V); subplot(3,3,6) imshow(Noisy) title('gaussian noise'); salt=imnoise(c,'salt & pepper',0.02); %加入椒盐躁声 subplot(3,3,7) imshow(salt) title('salt & pepper noise'); % fprintf(fp, '%d \n', dex); nameimg= [images( j ).name(1:end-4),'_0.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(b,imagepath); nameimg= [images( j ).name(1:end-4),'_1.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(c,imagepath); nameimg= [images( j ).name(1:end-4),'_2.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(erode,imagepath); nameimg= [images( j ).name(1:end-4),'_3.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(dilate,imagepath); nameimg= [images( j ).name(1:end-4),'_4.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(Noisy,imagepath); nameimg= [images( j ).name(1:end-4),'_5.bmp']; imagepath = fullfile( writepath, subdir( i ).name,nameimg); imwrite(salt,imagepath); endendfclose(fp);
0 0
- MATLIB 多个子文件夹批量创造测试文件
- MATLAB 读取多个子文件夹下相同格式的文件
- 怎样用matlab读取一个文件夹下的多个子文件夹中的多个图片文件
- autotools —— autoconf和automake生成Makefile文件(源文件位于多个子文件夹)
- windows系统文件夹下最多有多少个子文件
- cmd 批量删除文件、文件夹
- Matlab批量读取文件夹文件
- 批量根据文件建立文件夹并将文件移入文件夹
- 根据文件或者文件夹名批量删除文件或文件夹
- 批量修改文件、文件夹的隐藏属性
- 批处理:批量修改文件和文件夹权限
- 批量更改文件夹以及文件权限
- Android文件/文件夹批量蓝牙分享
- 批量去掉文件夹中的.svn文件
- 批量文件操作-批处理删除文件夹
- 批量复制文件或文件夹名
- 批量删除.svn文件夹、.svn文件
- 批量清理.svn(文件和文件夹)
- 初学安卓路之CheckBox与RadioGroup
- APK瘦身记,如何实现高达53%的压缩效果
- linux 内存清理/释放命令
- Freemaker初接触(五)导入公共ftl文件
- 此应用程序当前处于脱机状态
- MATLIB 多个子文件夹批量创造测试文件
- 李彦宏笑对“百度是做外卖的”质疑:外卖的技术含量是不低的
- linux下SVN服务器搭建
- permission denied 错误
- ubuntu +pyCharm配置Django
- vi全局替换方法
- android 自定义多视图切换View
- android_重要机制_内存管理机制
- 《提问的智慧》摘要