我在debianlinux上使用了python2.7以及matplotlib、Numpy、Scipy和PIL。
我可以用上面提到的代碼為圖像的hs和I參數生成一個直方圖。我打算對H S和I直方圖應用直方圖均衡化,然後将其轉換回生成的圖像,以便比較這些變化。有人能幫我處理直方圖均衡化的必要代碼并将均衡後的直方圖轉換回圖像嗎。在import scipy
from scipy import ndimage
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
from scipy import misc
import scipy.misc
img = scipy.misc.imread("/home/subhradeep/Desktop/testc.jpg")
array=np.asarray(img)
arr=(array.astype(float))/255.0
img_hsv = colors.rgb_to_hsv(arr[...,:3])
lu1=img_hsv[...,0].flatten()
plt.subplot(1,3,1)
plt.hist(lu1*360,bins=360,range=(0.0,360.0),histtype='stepfilled', color='r', label='Hue')
plt.title("Hue")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.legend()
lu2=img_hsv[...,1].flatten()
plt.subplot(1,3,2)
plt.hist(lu2,bins=100,range=(0.0,1.0),histtype='stepfilled', color='g', label='Saturation')
plt.title("Saturation")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.legend()
lu3=img_hsv[...,2].flatten()
plt.subplot(1,3,3)
plt.hist(lu3*255,bins=256,range=(0.0,255.0),histtype='stepfilled', color='b', label='Intesity')
plt.title("Intensity")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.legend()
plt.show()
我需要用python實作eq(4)