Python压缩图片

	
	resp = urllib.request.urlopen(imgurl)
	image = np.asarray(bytearray(resp.read()), dtype="uint8")
	image = cv.imdecode(image, cv.IMREAD_COLOR)

	#双三次插值
	height,width = image.shape[:2]  #获取原图像的水平方向尺寸和垂直方向尺寸。
	res = cv.resize(image,(int(0.3*width),int(0.3*height)),interpolation=cv.INTER_AREA)

	imge = Image.fromarray(cv.cvtColor(res,cv.COLOR_BGR2RGB))
	# 创建滤波器,使用不同的卷积核
	gary2 = imge.filter(ImageFilter.DETAIL)

	#图像点运算
	gary3=gary2.point(lambda i:i*0.9)

猜你喜欢

转载自blog.csdn.net/lidongxx/article/details/89145901
今日推荐