clc;
clear all;
maindir = 'F:\skype';
subdir = dir( maindir ); % 先确定子文件夹
for i = 1 : length( subdir )
if( isequal( subdir( i ).name, '.' ) || ...
isequal( subdir( i ).name, '..' ) || ...
~subdir( i ).isdir ) % 如果不是目录跳过
continue;
end
subdirpath = fullfile( maindir, subdir( i ).name, '*.jpg' );
images = dir( subdirpath ); % 在这个子文件夹下找后缀为jpg的文件
for j = 1 : length( images ) % 遍历每张图片
imagepath = fullfile( maindir, subdir( i ).name, images( j ).name );
rgb = imread( imagepath ); % 这里进行你的读取操作
R=rgb(:,:,1); %red
G=rgb(:,:,2); %green
B=rgb(:,:,3); %blue
[x,y,z]=size(rgb);
for t =1:x
for l =1:y
if( (R(t,l) == 0) && (G(t,l) == 0) && (B(t,l) == 0) )
R(t,l) = 255;
G(t,l) = 255;
B(t,l) = 255;
else
R(t,l) = 0;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载