Why python raise a runtime error while i run numpy.percentile for equalization by scikit-image?

让人想犯罪 __ 提交于 2019-12-12 06:38:05

问题


I take the equalization code from here

import numpy as np
from skimage import morphology
from skimage import color
from skimage import io
from matplotlib import pyplot as plt
from skimage import data, img_as_float
from skimage import exposure


img = color.rgb2gray(io.imread(path))

# Contrast stretching
p2 = np.percentile(img, 2)
p98 = np.percentile(img, 98)
#img_rescale = exposure.rescale_intensity(img, in_range=(p2, p98))
img_rescale = exposure.rescale_intensity(img, out_range=(0, 255))

# Equalization
img_eq = exposure.equalize_hist(img)

# Adaptive Equalization
img_adapteq = exposure.equalize_adapthist(img, clip_limit=0.03)

and when i use this kind of image:

image

i got this error:

Run time Error!

python stopped and respond:

this application has requested the runtime to terminate it in an unusual way!

at this line:

p2 = np.percentile(img, 2)

来源:https://stackoverflow.com/questions/22333700/why-python-raise-a-runtime-error-while-i-run-numpy-percentile-for-equalization-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!