Matlab 图像预处理
%%%%%%%%%%%%%%%%% %%降采样 clear all im={}; %创建字典保存读取的图片 dis=dir('F:\kaggle_data_zip\Sample\*.jpeg');%%找到所有需要进行预处理的图像 for i=1:length(dis) path=strcat('F:\kaggle_data_zip\Sample\',dis(i).name); im{i}=imread(path);%%读取图像 for k=1:3 %%分别对三个通道进行降采样 up_scale=5; %%将采样系数设置为5 im_gnd{i}(:,:,k)=modcrop(im{i}(:,:,k),up_scale); im_gnd{i}(:,:,k) = single(im_gnd{i}(:,:,k))/255; end figure,imshow(im_gnd{i});%%%这时显示的是进行降采样后的rgb图像 end %%%%%%%%%%%%%%%%%%%%%%%%%% LL=im_gnd{1}; B0 = imresize(LL(:,:,1),[512 512],'bilinear'); B1 = imresize(LL(:,:,2),[512 512],'bilinear'); B2 = imresize(LL(:,:,3),[512 512],'bilinear'); %%线性插值 %%%%%%%%%%%%%%%%%%%%%%% im1(:,:,1)=B0;&&&合并三个通道的图像 im1(:,:,2)=B1; im1(:,:,3)=B2; imshow(im1); %%%%%%%%%%%%%%%%%%%%%%%%%%%% A=cutblack2(im_gnd{1}(:,:,1));%%调用cutblack函数,得到裁剪位置 B=cutblack(im_gnd{1}(:,:,1)); imshow(im_gnd{1}(A(1):A(2),B(1):B(2),:)) %%裁剪RGB图像 %%%%%%%%%%%%%%%%%%%%%%%%%%%%