如何删除水平和垂直线(How to remove horizontal and vertical lines)

编程入门 行业动态 更新时间:2024-10-11 17:21:31
如何删除水平和垂直线(How to remove horizontal and vertical lines)

我需要删除二进制图像中的水平和垂直线。 有没有过滤这些行的方法? bwareaopen()不是很好的去除这些线条的方法,对于这些情况来说bwareaopen()和侵蚀也不是很好。 有人知道解决方案吗?

示例图像:

编辑:(添加更多示例图像:

http://s1.upload7.ir/downloads/pPqTDnmsmjHUGTEpbwnksf3uUkzncDwr/example%202.png

图像源文件:

https://www.dropbox.com/sh/tamcdqk244ktoyp/AAAuxkmYgBkB8erNS9SajkGVa?dl=0

www.directexe.com/9cg/pics.rar

I need to remove horizontal and vertical lines in a binary image. Is there any method for filtering these lines? bwareaopen() is not good method to remove these lines and also Dilation and Erosion are not good for these cases. Does any one know a solution?

Example image:

EDIT:(added more example images:

http://s1.upload7.ir/downloads/pPqTDnmsmjHUGTEpbwnksf3uUkzncDwr/example%202.png

source file of images:

https://www.dropbox.com/sh/tamcdqk244ktoyp/AAAuxkmYgBkB8erNS9SajkGVa?dl=0

www.directexe.com/9cg/pics.rar

最满意答案

使用regionprops并去除高偏心率(意思是该区域长而薄)和接近0或接近90度的方向(垂直或水平的区域)的区域。

码:

img = im2double(rgb2gray(imread('removelines.jpg'))); mask = ~im2bw(img); rp = regionprops(mask, 'PixelIdxList', 'Eccentricity', 'Orientation'); % Get high eccentricity and orientations at 90 and 0 degrees rp = rp([rp.Eccentricity] > 0.95 & (abs([rp.Orientation]) < 2 | abs([rp.Orientation]) > 88)); mask(vertcat(rp.PixelIdxList)) = false; imshow(mask);

输出:

在这里输入图像描述

Use regionprops and remove regions with high eccentricity (meaning the region is long and thin) and orientation near 0 or near 90 degrees (regions which are vertical or horizontal).

Code:

img = im2double(rgb2gray(imread('removelines.jpg'))); mask = ~im2bw(img); rp = regionprops(mask, 'PixelIdxList', 'Eccentricity', 'Orientation'); % Get high eccentricity and orientations at 90 and 0 degrees rp = rp([rp.Eccentricity] > 0.95 & (abs([rp.Orientation]) < 2 | abs([rp.Orientation]) > 88)); mask(vertcat(rp.PixelIdxList)) = false; imshow(mask);

Output:

enter image description here

更多推荐

图像,bwareaopen,www,com,images,电脑培训,计算机培训,IT培训"/> <meta name="

本文发布于:2023-08-05 19:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437941.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:垂直线   水平和   remove   lines   vertical

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!