When reading a low-contrast image it automatically take this example:
In [1]: from PIL import Image
In [2]: import numpy as np
In [3]: import matplotlib.pyplot as plt
In [4]: img = Image.open('images/map.jpg')
In [5]: arr = np.asarray(img)
In [6]: plt.gray()
In [7]: plt.imshow(arr)
Out[7]: <matplotlib.image.AxesImage at 0x7f9c7e88f490>
In [8]: plt.show()
Input
large
Plot (no change this is automatic by matplotlib.)
large
Because this input is different from the plot without, modifying anything.
I need low-contrast image to implement an algorithm to contrast stretching
Reading the book amazon Digital Image Processing (Rafael C. Gonzalez, Richard E. Woods)
PS: matplotlib is converting the automatic. I do not need.
If you do not want the automatic scaling of the colormap, you can use vmin
and vmax
to set the range you prefer, like this:
plt.imshow(arr, vmin=0, vmax=255)
When showing a numpy array, matplotlib can only automatically know the range of the actual input data (not the range it was taken from), so it takes the full input range an maps it to the full output range. But if you know a different range of the input data, you can use vmin
and vmax
to specify it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With