当前位置:网站首页>Definition, significance and characteristics of histogram
Definition, significance and characteristics of histogram
2022-07-08 02:20:00 【So come on】
The definition of histogram 、 Meaning and characteristics
1. Definition
In statistics , Histogram is a graphical representation of the distribution of data , It's a two-dimensional statistical chart , His two coordinates are statistical samples ( Images 、 Video frame ) And some attribute of the sample ( brightness , Pixel values , gradient , Direction , Color and so on ).
2. significance
(1) Histogram is a graphical representation of the intensity distribution of pixels in an image .
(2) The histogram counts the number of pixels of each intensity value .
3. features
(1) Histogram no longer represents any image texture information , But the statistics of image pixels .
(2) Because the same object, whether rotating or translating, has the same gray value in the image , Therefore, the histogram has translation invariance 、 Zoom invariance and other advantages .
4. Methods and parameters
cv2.calcHist(images, channels, mask, histSize, ranges[hist[, accumulate]])
(1)images : Integer type (uint8 and float32) Original graph (list Form shows ).
(2)channels : The index of the channel , for example :[0] Represents a grayscale image ,[0],[1],[2] Represents multi-channel .
(3)mask : Calculate the histogram of the specified area of the picture . If mask by none, Then calculate the whole picture .
(4)histSize( bins ) : Each hue value ( Range : 0 ~ 255) The corresponding number of pixels / frequency .[ this 256 Each of the values is called bin, Its value is 8,16,32,64,128,256. stay OpenCV in , use histSize Express bins.]
(5)range : Range of strength values ,[0, 256].
# 1 Import library
import cv2
import matplotlib.pyplot as plt
import numpy as np
# 2 Method : display picture
def show_image(image, title, pos):
# Sequential conversion :BGR TO RGB
image_RGB = image[:, :, ::-1] # shape : (height, width, channel) -1 Reverse order
# Show title
plt.title(title)
plt.subplot(2, 1, pos) # location
plt.imshow(image_RGB)
# 3 Method : Display the gray histogram of the picture
def show_histogram(hist, title, pos, color):
# Show title
plt.title(title)
plt.subplot(2, 1, pos) # Positioning pictures
plt.xlabel("Bins") # Horizontal axis information
plt.ylabel("Pixels") # Vertical axis information
plt.xlim([0, 256]) # Range
plt.plot(hist, color=color) # Draw histogram
# 4 The main function main()
def main():
# 5 Create a canvas
plt.figure(figsize=(15, 6)) # Canvas size
plt.suptitle("Gray Image Histogram", fontsize=14, fontweight="bold") # Set the title form
# 6 Loading pictures
img = cv2.imread("children.jpg")
# 7 Gray scale conversion
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 8 Calculate the histogram of gray image
hist_img = cv2.calcHist([img_gray], [0], None, [256], [0, 256])# list
# 9 Display gray histogram
# Gray scale image is converted into BGR Format picture
img_BGR = cv2.cvtColor(img_gray, cv2.COLOR_GRAY2BGR)
show_image(img_BGR, "BGR image", 1)
show_histogram(hist_img, "gray image histogram", 2, "m")
plt.show()
if __name__ == '__main__':
main()
边栏推荐
- mysql报错ORDER BY clause is not in SELECT list, references column ‘‘which is not in SELECT list解决方案
- Height of life
- Spock单元测试框架介绍及在美团优选的实践_第四章(Exception异常处理mock方式)
- Completion report of communication software development and Application
- LeetCode精选200道--数组篇
- JVM memory and garbage collection-3-runtime data area / heap area
- Deep understanding of cross entropy loss function
- Clickhouse principle analysis and application practice "reading notes (8)
- Leetcode question brushing record | 283_ Move zero
- 很多小伙伴不太了解ORM框架的底层原理,这不,冰河带你10分钟手撸一个极简版ORM框架(赶快收藏吧)
猜你喜欢
[knowledge map paper] r2d2: knowledge map reasoning based on debate dynamics
Learn CV two loss function from scratch (1)
Semantic segmentation | learning record (2) transpose convolution
Keras深度学习实战——基于Inception v3实现性别分类
[reinforcement learning medical] deep reinforcement learning for clinical decision support: a brief overview
Learn face detection from scratch: retinaface (including magic modified ghostnet+mbv2)
mysql报错ORDER BY clause is not in SELECT list, references column ‘‘which is not in SELECT list解决方案
1331:【例1-2】后缀表达式的值
Industrial Development and technological realization of vr/ar
MQTT X Newsletter 2022-06 | v1.8.0 发布,新增 MQTT CLI 和 MQTT WebSocket 工具
随机推荐
Nanny level tutorial: Azkaban executes jar package (with test samples and results)
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
#797div3 A---C
Literature reading and writing
Leetcode question brushing record | 283_ Move zero
VIM use
Ml self realization /knn/ classification / weightlessness
OpenGL/WebGL着色器开发入门指南
Relationship between bizdevops and Devops
Ml self realization / logistic regression / binary classification
Beaucoup d'enfants ne savent pas grand - chose sur le principe sous - jacent du cadre orm, non, ice River vous emmène 10 minutes à la main "un cadre orm minimaliste" (collectionnez - le maintenant)
Deep understanding of softmax
CBAM for in-depth understanding of the attention mechanism in CV
CV2 read video - and save image or video
Vim 字符串替换
Learn CV two loss function from scratch (2)
Talk about the realization of authority control and transaction record function of SAP system
Installing and using mpi4py
Random walk reasoning and learning in large-scale knowledge base
The way fish and shrimp go