Chain Code

Chain code can be used to describe a shape. We can use two main classes of chain code. One isabsolute chain code, another isrelative chain code.

For absolute chain code,we define a set of absolute directions. Then we code the shape as follows:


We start from the green pixel above and go clockwise. For each new pixel, we check the direction of the vector from the old pixel to the new pixel. As the second pixel is on the SW corner. So it’s code number is 5 by our definition. Go on until we return the start pixel. Then we get the chain code 5,5,7,1,1,3,3. This is a  shape feature vector. If we want to match a shape. What we do is just compare two vectors.

For relative chain code, the difference is that we don’t use absolute direction. Instead, we choose relative direction. In this method, when we want to get a chain code, we don’t check the absolute direction of the new pixel and the old pixel. We just check the relative direction of the direction. If the new pixel is frontier, then the code is 2. If it’s back, then the code is 6. What we need to take care of is that, in relative chain code, the start pixel’s chain code is decided by the last pixel.

The absolute chain code stores the position information of the shape, while relative chain code don’t. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值