SoFunction
Updated on 2024-11-19

Python Digital Image Processing Basics Histograms in Detail

Definition of Histogram

在这里插入图片描述

在这里插入图片描述

Properties of Histograms

在这里插入图片描述

Only counting aThe number of gray-level occurrences of the imageIf the sizes are different, the number of times a pixel with a certain gray value appears isIt's not the same.
So if we build on thatDivided by the total number of pixels, that would beprobability that a particular gray level occurs, then in that caseGray scale histogram of the same content image of different sizesIt's the same.

在这里插入图片描述

在这里插入图片描述

Applications of Histograms

image enhancement

在这里插入图片描述

image segmentation

在这里插入图片描述

image recognition

在这里插入图片描述

Calculation of Python Histograms

import cv2
import numpy as np
import  as plt
img = ('',0)
img = ()
img = ()
myhist = []
for i in range(0,256):
	((i))
['-serif'] = ['SimHei']  # Used to display Chinese labels
# [''] = 100 # Dots per inch
()
(x=range(0,256),height=myhist,width=0.5)
('Histogram')
("Grayscale values")
("Number of pixels")
()

Run the results graph:

在这里插入图片描述

Parameter settings.

import  as plt
['-serif']=['SimHei'] # Used to display Chinese labels
['axes.unicode_minus']=False # Used to display the negative sign
[''] = (16.0, 10.0) # Adjust the maximum size of the generated chart
[''] = 300 # of dots per inch
invocations()availablercParamsand the default values of all the parameters of the。
for example:
'': 100.0 dots per inch
'': [6.0, 4.0] Maximum size of generated charts
'': 10.0 Font Size
'': 10 Number of histogram bins
'': 1.5 line width
'': 'None' Marker styles
'': 'png' Format for saving pictures
'savefig.jpeg_quality': 95 Image quality
'': 'black' Text color
'timezone': 'UTC'  time zone format


Above is the detailed content of Python Digital Image Processing Basic Histogram, more information about Python Digital Image Processing Basic Histogram please pay attention to my other related articles!