PACAL VOC数据集格式的相关问题

  1. 获取指定像素值的坐标
    image_path = 'C:\\Users\\Yeh Chih-En\\Desktop\\test_images\\0bb0672f1afd6baaf94c516bcfb7dfae.png'
    image = Image.open(image_path)
    im_width, im_height = image.size
    count = 0
    for h in range(0,im_height):
        for w in range(0,im_width):
            pixel = image.getpixel((w,h))
            if pixel == 255:
                count += 1
                print('total:', count)
                print('w,h:', w,h)
  1. 对于模式为L的图像:8位像素,黑色和白色(0和255);
    模式为P的图像:8位像素,使用调色板映射到其他模式(PASCAL VOC里的分割数据是P模式
    在我的图片中,将L转换成P后,0像素值部分转换成1, 255像素值部分转换成0
    print(image.mode)
    new_image = image.convert("P", palette = Image.ADAPTIVE)
    print('new:',new_image.getpixel((631,309))) # 0
    print(image.getpixel((631,309))) #255
    
    print('new:',new_image.getpixel((1,1))) # 1
    print(image.getpixel((1,1))) #0
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值