雪碧探测包
spriteutil-lqnhat的Python项目详细描述
精灵探测
特点
- [x] 找出图像中最常见的颜色。在
- [x] 在图像中查找精灵。在
- [x] 绘制精灵标签边界框。在
为什么这个项目有用?
- 采用合理的工艺图像库。在
- 可用于大图像。在
- 容易理解。在
用法
- 找出图像中最常见的颜色
>>>fromPILimportImage# JPEG image>>>image=Image.open('first_image.jpg')>>>image.mode'RGB'>>>find_most_common_color(image)(0,221,204)# PNG image>>>image=Image.open('second_image.png')>>>image.mode'RGBA'>>>find_most_common_color(image)(0,0,0,0)# Grayscale image>>>image=image.convert('L')>>>image.mode'L'>>>find_most_common_color(image)0
- 在图像中查找精灵。在
其他示例,如下图所示:
>>>fromPILimportImage>>>image=Image.open('optimized_sprite_sheet.png')>>>sprites,label_map=find_sprites(image)>>>len(sprites)22>>>forlabel,spriteinsprites.items():...print(f"Sprite ({label}): [{sprite.top_left}, {sprite.bottom_right}] {sprite.width}x{sprite.height}")Sprite(25):[(383,1),(455,102)]73x102Sprite(43):[(9,2),(97,122)]89x121Sprite(26):[(110,4),(195,123)]86x120Sprite(46):[(207,4),(291,123)]85x120Sprite(16):[(305,8),(379,123)]75x116Sprite(53):[(349,125),(431,229)]83x105Sprite(61):[(285,126),(330,181)]46x56Sprite(100):[(1,129),(101,237)]101x109Sprite(106):[(106,129),(193,249)]88x121Sprite(93):[(183,137),(278,241)]96x105Sprite(95):[(268,173),(355,261)]88x89Sprite(178):[(6,244),(101,348)]96x105Sprite(185):[(145,247),(245,355)]101x109Sprite(141):[(343,257),(417,372)]75x116Sprite(169):[(102,262),(142,303)]41x42Sprite(188):[(249,267),(344,373)]96x107Sprite(192):[(412,337),(448,372)]37x36Sprite(256):[(89,353),(184,459)]96x107Sprite(234):[(11,356),(104,461)]94x106Sprite(207):[(188,358),(281,463)]94x106Sprite(229):[(384,374),(456,475)]73x102Sprite(248):[(286,378),(368,482)]83x105
- 绘制精灵标签边界框。在
>>>fromPILimportImage>>>image=Image.open('optimized_sprite_sheet.png')>>>sprites,label_map=find_sprites(image)>>># Draw sprite masks and bounding boxes with the default white background color.>>>sprite_label_image=create_sprite_labels_image(sprites,label_map)>>>sprite_label_image.save('optimized_sprite_sheet_bounding_box_white_background.png')>>># Draw sprite masks and bounding boxes with a transparent background color.>>>sprite_label_image=create_sprite_labels_image(sprites,label_map,background_color=(0,0,0,0))>>>sprite_label_image.save('optimized_sprite_sheet_bounding_box_transparent_background.png')
Sprite Masks with White Background | Sprite Masks with Transparent Background |
---|---|
使用
构建作者
- 乐广一行(masternhat)-Intek学生-开发者
拉请求欢迎!
发现错误了吗?有什么不合理的吗?给我发个pull request!在
支持
在这里提问:https://www.google.com/
每个人都可以保持贡献
只需执行以下步骤:
- 叉开(https://github.com/intek-training-jsc/sprite-detection-masternhat.git)
- 创建您的功能分支(
git checkout -b feature/fooBar
) - 提交更改(
git commit -am 'Add some fooBar'
) - 推送到分支(
git push origin feature/fooBar
) - 创建新的拉取请求
许可证
这个项目是在麻省理工学院许可下授权的-有关详细信息,请参阅LICENSE.md文件
- 项目
标签: