python中imread为何无法使用_无法使用imread()加载图像

问题是你的图像不包含任何非零的红、绿或蓝像素,它完全是黑色的。{PNG的背景显示出黑色和透明性,这是因为它显示了透明性。在

如果你用ImageMagick的identify来观察它,你会看到:identify -verbose a.png | more

Image: a.png

Format: PNG (Portable Network Graphics)

Mime type: image/png

Class: DirectClass

Geometry: 203x50+0+0

Resolution: 37.79x37.79

Print size: 5.37179x1.3231

Units: PixelsPerCentimeter

Colorspace: sRGB

Type: Bilevel

Base type: Undefined

Endianess: Undefined

Depth: 8-bit

Channel depth:

Red: 1-bit

Green: 1-bit

Blue: 1-bit

Alpha: 8-bit

Channel statistics:

Pixels: 10150

Red:

min: 0 (0)

max: 0 (0)

mean: 0 (0)

standard deviation: 0 (0)

kurtosis: -3

skewness: 0

entropy: 0

Green:

min: 0 (0)

max: 0 (0)

mean: 0 (0)

standard deviation: 0 (0)

kurtosis: -3

skewness: 0

entropy: 0

Blue:

min: 0 (0)

max: 0 (0)

mean: 0 (0)

standard deviation: 0 (0)

kurtosis: -3

skewness: 0

entropy: 0

Alpha:

min: 0 (0)

max: 255 (1)

mean: 16.477 (0.0646159)

standard deviation: 58.73 (0.230314)

kurtosis: 10.7342

skewness: 3.50997

entropy: 0.128008

...

...

Background color: white

...

...

答案是用cv2.IMREAD_UNCHANGED读取所有四个通道,只需使用第四个/alpha通道:

^{pr2}$

从here提取的代码。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值