开发者

OpenCV binary filter which sets a pixel to background if ALL neighbors are background

I'm looking for an OpenCV image filter that works on binary images. Basically what I want is the filter to set a foreground pixel to background, if and only if all 8 of its neighbors are background. It should not touch any pixels that are background. Those should always stay backgroun开发者_如何学编程d.

Thanks in advance!


Two possible ways of going about this:

  1. You'll have to use Get2D() and put the image pixels into a 2-D array. Then manually check with a 3x3 mask for pixels neighbors that are background. This would be the lengthy but failsafe method OR

  2. Read up on morphological opening using cvMorphologyEx() function: it basically removes small bright regions in image. The default morphology kernel is a 3x3 anchored at center so that will correspond to your requirement of 8 neighbors.

    Late response to the question but do see if these work. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜