最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python如何实现位图分割效果 Python实现位图分割效果代码示例
时间:2022-06-25 01:34:36 编辑:袖梨 来源:一聚教程网
Python如何实现位图分割效果?本篇文章小编给大家分享一下Python实现位图分割效果代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
代码如下
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('Fig3.13.jpg', 0)
imgBS = np.zeros_like(img)
plt.figure("Image")
plt.subplot(2, 4, 1)
plt.imshow(img, cmap='gray')
plt.axis('off')
plt.title('original')
for n in range(1, 8):
for x in range(img.shape[0]):
for y in range(img.shape[1]):
gray = img[x, y] & pow(2, n-1)
if gray == pow(2, n-1):
imgBS[x, y] = 255
else:
imgBS[x, y] = 0
plt.subplot(2, 4, n+1)
plt.imshow(imgBS, cmap='gray')
plt.axis('off')
plt.title(str(n) + 'bit')
plt.show()
结果:
相关文章
- 魔法工艺叠毒流玩法攻略 05-22
- 第四届中国AIGC产业峰会时间确认了吗?5个常见问题避坑指南 05-22
- 龙城秘境神器系统怎么玩 05-22
- 三角洲行动与明日方舟联动皮肤怎么样 05-22
- 第四届中国AIGC产业峰会怎么举办?亲测有效,避开4个常见误区 05-22
- 代号妖鬼龙宫纯射流玩法攻略 05-22

