Algorithm of Contour Detection Improvement (2)

To combine the objects, first, we should detect whether the intersection line is flat. As I have said, it may fail in some cases. But in many cases, it is enough. And it can reduce the running time. So there comes the question: how do we difine a flatness of a line?


To solve this question, I define a method to calculate the faltness of a line. We all know that the line in the computer is just combined by pixels in the screen. So every point in the line will be neighbour to another points. So, for every pont in  the line, I will check its neighbour points. If the neighbour points are level to this, then I treat it flat and assign 0 to this point. But if we have a point that is vertical to this, Then I treat it bad case and assign it 10. So, at last, every point has a mark. I will calculate the average point tosee if it is flat. There are some examples followed.



We can see the right two pictures are all flat lines and their mark is below than 1. But the left lines are not so good and their marks are more than one. So, this method can detect level line. And After we detect the line, we want to combine the right case.


At first, we must know that what case we want to do and what case we do not want. So see the picture.



What we want to do is combine such cases. We want to combine the case whose intersection line is level and boder is continus. See the picture above, the blue line is level and the green line is continus. This is the case we want to do. And rememner, we will only do the case whose two sides of boder lines are all level. If one side boder is continus and another is not, we will not get this because it may lead error.


So, another question comes. How could we say that the boder is continus? In this question, I use straight line to fit the boder line. We can see that there are two boder lines starting from the end point. So, we have two lines. And every line we have two k value(y = k * x). So, we can test the difference of k value and make a threshold. If we have a difference which is less than the k, we can combine them.


Ok, the algorithm is just like this. And I'm sure that we can improve it. Below is a result.




Thank you!


The code is here. http://download.csdn.net/detail/lcbwlx/6923377

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值