1. A method of modifying the histogram of a grayscale image to improve contrast, comprising: extracting black connected components from the grayscale image that touch at least one of the margins of the grayscale image; computing the histogram of the portion of the grayscale image covered by the extracted black connected components; and updating the histogram of the grayscale image by subtracting the histogram of the portion of the binary image covered by the extracted black connected components from the histogram of the grayscale image or by subtracting a function of number of pixels of the portion of the binary image covered by the extracted black connected components from the histogram of the grayscale image.