如何使用“xphoto”_白色平衡器.balanceWhite“用Python和OpenCV?

2024-10-01 13:42:59 发布

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

我正在寻找一个直接的方式应用自动白平衡的图像。在

我找到了一些关于balanceWhite()方法的官方文档:cv::xphoto::WhiteBalancer Class Reference

但是,当我尝试调用示例中所示的函数时,有一个模糊的错误。在

image = cv2.xphoto_WhiteBalancer.balanceWhite(image)

加薪:

^{pr2}$

如果我尝试根据需要使用cv2.xphoto_WhiteBalancer对象:

balancer = cv2.xphoto_WhiteBalancer()
cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)

它引发了:

Traceback (most recent call last):
  File "C:\Users\Delgan\main.py", line 81, in load
    cv2.xphoto_WhiteBalancer.balanceWhite(balancer, image)
TypeError: Incorrect type of self (must be 'xphoto_WhiteBalancer' or its derivative)

有人在python3.6和opencv3.4中成功地使用了这个特性吗?在

我也尝试过使用派生类GrayworldWBLearningBasedWB和{},但错误是相同的。在


Tags: 方法文档图像image官方错误方式cv2
1条回答
网友
1楼 · 发布于 2024-10-01 13:42:59

答案可以在^{} documentation中找到。在

创建WB算法的合适方法是createSimpleWB()createLearningBasedWB()和{}。在

示例:

wb = cv2.xphoto.createGrayworldWB()
wb.setSaturationThreshold(0.99)
image = wb.balanceWhite(image)

下面是官方OpenCV存储库中的一个示例文件:^{}

相关问题 更多 >