JAVA版opencv透明,OpenCV-将PNG的透明部分变成白色

新手在尝试使用OpenCV处理一组带有透明边框的PNG图像。目标是消除这些边框,考虑使用边缘检测,但希望能将透明部分直接转换为白色。在文档中找到了将PNG的透明度通道移除并将其变为黑色的方法,询问是否存在类似方法将边框转为白色,或者更简单的消除边框的方法。最终,提供了使用IMREAD_UNCHANGED加载图片,然后通过阈值处理透明通道创建掩模,结合位运算将对应部分转为白色的解决方案。
摘要由CSDN通过智能技术生成

I am new to OpenCV so please bear with me if my qustion seems silly to you.

I have a set of images who all have a transparent border on the left and right like you can see below:

WYU1v.png

I want to erase these borders so I thought about edge detection which would be easy to do if I could transform these transparent borders to a white color. In the Docs I found that you can do this:

img = cv2.imread("./Green/image-000.png", 1)

cv2.imwrite('../image-000.png', img)

This erases the alpha channel of the png image but turns it into black.

Is there something similar that turns the borders white?

Or is there even a simpler method of erasing these borders?

You would make me really happy if you could help me!

PS: I use Python 2.7 and Ope

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值