为什么python在我运行时引发运行时错误百分位用scikitimage均衡?

2024-05-26 11:09:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我从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)

当我使用这种图像时:

image

我有个错误:

^{pr2}$

python停止并响应:

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

在这一行:

p2 = np.percentile(img, 2)

Tags: infromioimportimgasnpcolor