为什么直方图均衡化上不显示图像:python
我正在尝试对图像进行直方图均衡。当我运行程序时,既不会显示输出图像,也不会显示错误 谁能告诉我哪里出了问题试试:为什么直方图均衡化上不显示图像:python,python,image,image-processing,Python,Image,Image Processing,我正在尝试对图像进行直方图均衡。当我运行程序时,既不会显示输出图像,也不会显示错误 谁能告诉我哪里出了问题试试: import numpy as np import cv2 import scipy.misc, math from scipy.misc.pilutil import Image while True: img = Image.open('img.jpg').convert(L) img1 = scipy.misc.fromimage(img) f1 = im
import numpy as np
import cv2
import scipy.misc, math
from scipy.misc.pilutil import Image
while True:
img = Image.open('img.jpg').convert(L)
img1 = scipy.misc.fromimage(img)
f1 = img1.flatten()
hist,bins = np.histogram(img1, 256,[0,255])
cdf = hist.cumsum
cdf_m = np.ma.masked_equal(cdf,0)
cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
cdf = np.ma.filled(cdf_m,0)
im2 = cdf[f1]
im3 = np.reshape(im2,img1.shape)
im4 = scipy.misc.toimage(img3)
im4.show()
您是否也将scipy.misc.toimage(img3)更改为scipy.misc.toimage(im3)?是的…这是一个输入错误。任何其他的解决方案为什么它不起作用呢?我不太了解PIL来回答你的问题,但是如果你在你的sstem上提到PIL的版本可能会有所帮助。python-c“导入PIL;打印(PIL.VERSION);打印(PIL.pull\u VERSION)”print是什么?将输出粘贴到您的问题中,这样人们就不必在评论中翻找来查看它。
import numpy as np
import cv2
import scipy.misc, math
from scipy.misc.pilutil import Image
while True:
img = Image.open('img.jpg').convert(L)
img1 = scipy.misc.fromimage(img)
f1 = img1.flatten()
hist,bins = np.histogram(img1, 256,[0,255])
cdf = hist.cumsum
cdf_m = np.ma.masked_equal(cdf,0)
cdf_m = (cdf_m - cdf_m.min())*255/(cdf_m.max()-cdf_m.min())
cdf = np.ma.filled(cdf_m,0)
im2 = cdf[f1]
im3 = np.reshape(im2,img1.shape)
im4 = scipy.misc.toimage(im3)
im4.format = "PNG" # out of paranoia mainly
im4.show()