这是你如何腐蚀图像并提取霍夫线:
I=rgb2gray(imread('https://i.stack.imgur.com/cbHFL.jpg'));
Ibw=I>200;
imshow(Ibw)
SE=strel('disk',1)
Ier=imerode(~Ibw,SE);
[H,T,R] = hough(Ier);
P = houghpeaks(H,100,'threshold',ceil(0.1*max(H(:))));
lines = houghlines(Ier,T,R,P);
%% plot
imshow(I);hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','blue');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
end
从这里,您可以开始考虑要删除的内容。除非你有一个符号字典,否则这并不简单,例如你如何删除带有>-<
形状的结构周围的线?您是删除所有中间像素还是保留整个中间细条?只有知道符号在没有粗线的情况下应该是怎样的,才能知道这一点。