# (个人)基于深度学习的中国传统特色图像的风格迁移创新实训第八周（2）

for i =1:M
Q =B{i};
N =size(Q,1);
if N<300
fill(Q(:,2),Q(:,1),[1 0 0]);

end
hold on;
end
frame=getframe(gcf);
im=frame2im(frame);
[m,n,k] =size(im);
for i =1:m
for j =1:n
if im(i,j,2)<125
im(i,j,1)=255;
im(i,j,2)=0;
im(i,j,3)=0;

end
end
end

se =strel('disk',2);
im=imerode(im,se);
se1 =strel('disk',3);
im =imdilate(im,se1);
figure(2);
imshow(im);

I_bw=im2bw(im);
L =bwlabel(I_bw);
Max=max(L(:));

distance=999999;
figure(3);
imshow(im,'Border','tight');
hold on
set(gcf,'color','r');
for i =1:Max
distance=999999;
[x,y] =find(L==i);
size_x =size(x);
for j =1:Max
if j~=i
[x1,y1] =find(L==j);
size_x1 =size(x1);
for a =1:size_x
for c =1:size_x1

temp_distance =abs(x(a)-x1(c))+abs(y(a)-y1(c));
if temp_distance<distance
a1=x(a);
b1=y(a);
c1=x1(c);
d1=y1(c);
distance =temp_distance;
end

end
end
end
if distance<7
plot([b1,d1],[a1,c1],'r','LineWidth',2);
hold on
end
distance =999;
end

frame=getframe(gcf);
im=frame2im(frame);
imwrite(im,'c.jpg','jpg');
end

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120