Transforms any gray-level or color image to a binary image using a static gray-level threshold.
image: Input image
level: Gray-level threshold. Every pixel with a gray level less than the threshold is regarded as background.
invert: Inversion flag. If this value is
true, inverts the result so that pixels whose gray level is less than level are regarded as foreground.
image: Gray-level 8-bit image. Background is zero, foreground is 255.