有人可以解释这个源代码。用于训练反向传播的图像处理。我想要二进制作为我的训练输入,但它不起作用。我在matlab中处理了大约500张图像。
clc
close all
clear all
feature_extraction = [];
feature_extra = [];
j1=1;
j2=1;
for j=1:500
RGB = imread(['frame',num2str(j),'.jpg']);
img_crop = RGB;
I= rgb2gray(RGB);
I = imresize(I,[80 64],'bicubic');
figure, imshow(I);
BW = edge(I,'canny',0.25); %Finding the edges of the image
[imx,imy]=size(BW);
msk=[0 0 0 0 0;
0 1 1 1 0;
0 1 1 1 0;
0 1 1 1 0;
0 0 0 0 0;];
B=conv2(double(BW),double(msk)); %smoothing the image to reduce the number of connected components
figure,imshow(B);
A=im2bw(B);
bw_resize=imresize(A,[70,50]);
data_target(j1,j2) = 1;
j2 = j2+1;
end
j1 = j1+1;
end