from WPIGrayscaleImage.java (from the WPIJavaCV project):
Code:
/**
* Returns a black and white image where every pixel that is higher (in the 0-255 scale) than the given threshold is <bold>white</bold>,
* and everything below is <bold>black</bold>.
* @param threshold a value 0-255. if a pixel has a value below the theshold, it becomes black
* if the pixel value is above or equal to the threshold, the pixel becomes white
* @return a new {@link WPIBinaryImage} that represents the threshold
*/
public WPIBinaryImage getThreshold(int threshold) {
validateDisposed();
IplImage bin = IplImage.create(image.cvSize(), 8, 1);
cvThreshold(image, bin, threshold, 255, CV_THRESH_BINARY);
return new WPIBinaryImage(bin);
}
It says that getThreshold() is black for [0,threshold) and white for [threshold, 255] - though, if you look at the OpenCV documentation for cvThreshold, it says that it's black for [0,threshold] and white for (threshold,255]. Either way, white is somewhere above, black is somewhere below.
The companion function getThresholdInverted() simply reverses the ranges, and if you compare getThreshold() and getThresholdInverted() from the same image with the same threshold, they should be perfect negatives.