Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of basic histogram of Python Digital Image processing

Shulou Source: shulou.com Published: 2022-06-03 09:14:08 10月01日 Update

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!

Tags: Histogram image grayscale article base number pixel size point image processing number example analysis processing maximum parameter picture chart size label Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Shulou Tech Info Redmi MySQL