Thresholding

One of the simplest methods of segmenting a grayscale image is using the threshold technique. It will basically set pixels below a given value as belonging to the interested object and the other pixels as not being part of it. Although it might suffer from illumination issues as well as problems that arise from variation inside the object, this can be enough when segmenting text in a page scan for OCR or to find a checkboard when calibrating the camera. Besides, some more interesting approaches, such as the adaptive threshold, can also yield good results in images that suffer from non-homogeneous lightning.

Basic thresholding is accomplished by means of Imgproc's threshold function, whose signature is as follows:

public static double ...

Get OpenCV 3.0 Computer Vision with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.