Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the effect of Bitmap Segmentation by Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "Python how to achieve the effect of bitmap segmentation". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "Python how to achieve the effect of bitmap segmentation" together!

No more words, just code.

import cv2import numpy as npimport matplotlib.pyplot as pltimg = 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() Thank you for reading, the above is the content of "Python how to achieve the effect of bitmap segmentation", after learning this article, I believe everyone on Python how to achieve the effect of bitmap segmentation This problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report