autolevel
题目
If we obtain and observe the histogram of an image, we can see that, typically, pixels are not filled all ranges of its gray scale values. More specifically, there are no pixels near gray scale 0, or gray scale 255. Of course, this varies from image to image. From what we learn in class, an image with such a histogram will demonstrate itself with low contrast. Besides histogram equalization, we can define an adaptive gray scale transform to make this kind of images with higher contrast. Assume l and h, respectively, the lowest and highest pixel value in the image. we can define the gray scale transform as: s = 255*(r-l)/(h-l), where r is input gray scale value, and s is transformed. In the above equation, when the resulting s is not integer, rounding to its nearest integer should be applied. For example, 0.4 should be rounded to 0, and 0.5 to 1 This image adaptive gray scale transform is called autolevel, which one can find in most popular photo toching software, such as photoshop, gimp and so forth. The purpose of this project is to implement autolevel. and gives processing result of a sample image, lena.bmp One should read in Lenna.jpg and convert it to grayscale (for this, one can use readimg.py listed in ppt). Implement the proto-type function: GenAutolevelMapping, and then implement the proto-type function ImageAutolevel, In the prototype function Main, one should accomplish the whole task. proto-type functions are already provided in the autolevel.py script, for which, one should not modify any of the first two prototype functions presented above!upload code and resulting image to your repository, the resulted image should be named to aLenna.bmp ( a file with not exact the same name will not be accepted! )Also note, never ever modify the name and parameters of the prototype functions provided in the py files
代码
1 | import numpy as np |