Use the threshold and invertimage functions to discard all of an image's intensity levels below or above a threshold, or to invert them. Thresholding can be used to remove background features (or noise) in an image or to shift its intensity spectrum. Inversion can be used to enhance details.
This function can be used in two ways. When thresh is positive, elements of M less than thresh are set to zero; otherwise they retain their original value. When thresh is negative, elements of M greater than the absolute value of thresh are set to zero; otherwise they retain their original value. When thresh is zero, all elements are set to zero.
1. Read in a test image.
(earth.bmp)
2. Set the cutoff threshold and view the effect on the above image.
(earth_t100.bmp)
Try different values of thresh, and then recalculate to see the effect on the image. Try some negative numbers too.
invertimage
The returned matrix contains the inverted elements of the original image. The value of the inverted element depends on the maximum value of the input matrix.
1. Invert the original image.
(earth_inv.bmp)
For grayscale images, this is equivalent to a "photographic" negative.
2. Read in a color image.
(apecolor.gif)
3. Invert the color image.
(apecolor_inv.bmp)
For color images, the effect is simply to replace all colors with their color complements.
4. Change the range of intensities of the original image.