![](/img/trans.png)
[英]Removing points from list if distance between 2 points is below a certain threshold
[英]Removing pixels below a certain threshold
您是在寻找一种可以自动去除任何给定图像背景的功能,还是可以过滤掉满足该特定图像特定条件的像素的功能?
eval 函数对图像中的每个像素应用相同的变换。 这适用于您的形象。
with Image.open("jFmbt.jpg") as im:
im = im.convert("L")
out_image = Image.eval(im, lambda x: 256 if x > 175 and x < 250 else x)
一个非常常用的库是OpenCV 。
import cv2 as cv
# 0 flag -> read image as greyscale
img = cv.imread("img.jpg", 0)
# threshold
ret, thresh = cv.threshold(img, 150, 255, cv.THRESH_BINARY)
# result
cv.imwrite("output.jpg", thresh)
结果图像将是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.