根据给定的阈值修改数值数组或图像

modify a numerical array or an image based on the given threshold

我有一张图片,想根据给定的阈值修改图片。

等函数
binary = image > threshold 

将创建二进制图像。我想要的是如果它高于阈值,图像像素将保持不变。有什么方便的功能吗?

image[image < threshold] = 0

会将低于阈值的每个像素裁剪为 0,并保持其余像素不变