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

Example Analysis of basic histogram of Python Digital Image processing

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the Python digital image processing basic histogram example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.

Definition of histogram

Properties of histogram

Only count the number of occurrence of a certain grayscale, if the size of the image is different, the number of pixels of a certain gray value is not the same.

Well, if we divide by the total number of pixels on this basis, that is the probability of the occurrence of a certain gray level, then the gray histogram of the same content image of different sizes is the same.

Application of histogram Image Enhancement

Image segmentation

Image recognition

Calculation of Python histogram import cv2import numpy as npimport matplotlib.pyplot as pltimg = cv2.imread ('cameraman.tif' 0) img = img.flatten () img = img.tolist () myhist = [] for i in range (0256): myhist.append (img.count (I)) plt.rcParams ['font.sans-serif'] = [' SimHei'] # used to display the Chinese label # plt.rcParams ['figure.dpi'] = 100 # dots per inch plt.figure () plt.bar (x=range (0256), height=myhist Width=0.5) plt.title ('histogram') plt.xlabel ('grayscale value') plt.ylabel (number of pixels) plt.show ()

Run result diagram:

Plt.rcParams parameter settings:

Import matplotlib.pyplot as pltplt.rcParams ['font.sans-serif'] = [' SimHei'] # is used to display the Chinese label plt.rcParams ['axes.unicode_minus'] = False # to display the negative sign plt.rcParams [' figure.figsize'] = (16.0,10.0) # adjust the maximum size of the generated chart plt.rcParams ['figure.dpi'] = 300 # call plt.rcParams.keys () per inch to get all the parameters and default values of rcParams. For example: 'figure.dpi': 100.0 dots per inch' figure.figsize': [6.0 Maximum size of the generated chart 'font.size': 10.0Font size' hist.bins': 10 histogram sub-boxes number of 'lines.linewidth': 1.5 lineweight' lines.marker': 'None' tag style' savefig.format': 'png' saved picture format' savefig.jpeg_quality': 95 picture quality 'text.color':' black' text color 'timezone' UTC' time zone format Thank you for reading this article carefully I hope the article "sample Analysis of the basic histogram of Python Digital Image processing" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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