Ask Your Question
0

Rounding a jagged contour

asked 2018-12-06 00:54:15 -0600

Martian gravatar image

Does OpenCV have any methods for gently rounding contours in a binary (black and white) image? Often, contour detection results in some rough edges, usually as a result of noise or other anomalies. I'd like to incrementally round out the spikey sections and fill in sharper indentations without too much loss in resolution or accuracy over the rest of the contour. IOW, most of the contour lines already smooth enough.

Dilate-Erode cycles would no doubt affect the accuracy of the entire contour, not just the aberrant areas.

I've heard of CRFs (Conditional Random Fields) used for this in some apps, but haven't found anything directly usable.

(Important to note that I'm not talking about Gaussian smoothing. This is a binary image--no gray scale).

edit retag flag offensive close merge delete

Comments

i did not understand your question well ( maybe an image will be helpful) but see https://stackoverflow.com/questions/2...

sturkmen gravatar imagesturkmen ( 2018-12-06 05:10:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-07 05:37:56 -0600

Martian gravatar image

updated 2018-12-07 05:39:03 -0600

Thanks for your reply and the link, Sturkmen. I probably over-explained that. I'm looking for something that would work kind of like dilate-then-erode: Simply straighten out jagged edges of a binary outline. But dilate-erode has side-effects that I'd like to avoid. The solution at your link appears to be on the right track but it looks like it blurs edges. I'm dealing with binary mask-like images. Perhaps it would be possible to convert to gray-scale, do Gaussian blur, then threshold to get back to the binary format. I'm not clear on whether that would work. I've heard of CRF-based functions that do this, but it looks like those are not yet incorporated into OpenCV.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-06 00:54:15 -0600

Seen: 2,372 times

Last updated: Dec 06 '18