Skip to content

Commit badd657

Browse files
authored
Add files via upload
1 parent bc475e2 commit badd657

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Pretreatment/cutImg.m

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
%% crop the im into 256*256
2+
3+
clear;clc;
4+
file_path = 'D:\ALL_DataSet\BSDS\train_HR_4\'; % 设定你存放图片的目录
5+
img_path_list = dir(strcat(file_path, '*.png')); % 选后缀为 .png 的图片
6+
img_num = length(img_path_list); %获得图片数量
7+
8+
for j = 1:img_num
9+
image_name = img_path_list(j).name;
10+
image = imread(strcat(file_path, image_name));
11+
[m,n]=size(image);
12+
if m == 481
13+
crop_image = imcrop(image, [0, 0, 320, 320]); % 使用 imcrop() 函数来裁剪图片,第二个参数的格式为 [XMIN YMIN WIDTH HEIGHT]
14+
else
15+
crop_image = imcrop(image, [0, 0, 320, 320]); % 使用 imcrop() 函数来裁剪图片,第二个参数的格式为 [XMIN YMIN WIDTH HEIGHT]
16+
end
17+
18+
imwrite(crop_image, strcat('D:\ALL_DataSet\BSDS200\train_HR_4\', image_name)); % 保存文件
19+
end

0 commit comments

Comments
 (0)