In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
In [2]:
im = plt.imread('testim.png')
print(im.dtype, im.shape, np.min(im), np.max(im))
plt.imshow(im)
Out[2]:
In [3]:
def contrast_adjustmenst(im, c, l):
return (c * (im ** l))
In [4]:
plt.imshow(contrast_adjustmenst(im, 1, 0.37))
Out[4]:
In [5]:
plt.imshow(contrast_adjustmenst(im, 1, 1.37))
Out[5]:
In [6]:
def contrast_scaling(im):
rmax, rmin = np.max(im, axis=(0, 1)), np.min(im, axis=(0, 1))
return (im - rmin) / (rmax - rmin)
In [7]:
im = plt.imread('testim.png')
im[im<0.2] = 0.2 # for illustration purpose
im[im>0.8] = 0.8 # for illustration purpose
plt.figure(figsize=(8, 8))
plt.subplot(121)
plt.imshow(im)
plt.subplot(122)
plt.imshow(contrast_scaling(im))
Out[7]:
In [ ]: