Ask Your Question
0

Adaptive threshold

asked 2014-03-21 21:44:03 -0600

Luek gravatar image

Someone suggested an adaptive threshold for me to get a desired result, however after messing with the parameters and settings I cannot get a similar result.

Here is the base image:

image description

How can I get from that image to this image using an adaptive threshold?

image description

Here is a snippet of what I've been trying

adaptiveThreshold(thr, thr, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 101, 16);

edit retag flag offensive close merge delete

Comments

Why are you using such a large block size (101) and why are you subtracting 16 from the weighted threshold? Both of those values seem excessive.

unxnut gravatar imageunxnut ( 2014-03-21 21:54:50 -0600 )edit

That code snippet probably wan't the best example, but it was just mean trying to learn how these values effect the end result.

Luek gravatar imageLuek ( 2014-03-21 21:56:21 -0600 )edit

Try removing the last two parameters and let them go by default.

unxnut gravatar imageunxnut ( 2014-03-21 22:15:25 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-03-23 03:13:25 -0600

Melgor gravatar image

First of all, read this documentation and see how the result look: DOCS

You should deeply analyse the result from chessboard - there you can see, that adaptive threshold is sth like edge detector. It will detect (set maximum value in you case) only the pixels, which in their local neighborhood has bigger value that "MEAN" + "C". So, the value from pixels ex. (0,0) and (1000,1000) are independent. As I say, this function will detect you edges, not blobs.

In this situation I suggest do sth like to detect blobs: - adaptiveThreshold: find edges in image - findContur: make connected component algorithm (you may to use OPEN or CLOSE morphological operation morphology to delete singe pixels or to connect to edges) - find biggest contour (by area or number of points) and fillPoly it with white color

After this operation you should get sth like you want.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-21 21:44:03 -0600

Seen: 1,288 times

Last updated: Mar 23 '14