当前位置:网站首页>HSV color model and color component range in opencv
HSV color model and color component range in opencv
2022-06-21 14:30:00 【Modest learning and progress】
https://www.cnblogs.com/wangyblzu/p/5710715.html
HSV Color model
HSV(Hue, Saturation, Value) According to the intuitive characteristics of color A. R. Smith stay 1978 A color space created in , Also known as the hexagonal cone model (Hexcone Model).、 The parameters of color in this model are : tonal (H), saturation (S), brightness (V).
tonal H: Measure in terms of angles , The value range is 0°~360°, Counting counter clockwise from red , Red as 0°, Green is 120°, Blue 240°. Their complementary color is : Yellow is 60°, Blue is 180°, Fuchsin is 300°;
saturation S: The value range is 0.0~1.0;
brightness V: The value range is 0.0( black )~1.0( white ).
RGB and CMY Color models are hardware oriented , and HSV(Hue Saturation Value) The color model is user oriented .
HSV The three-dimensional representation of the model starts from RGB The cube evolved . Imagine from RGB Look at the black vertices along the diagonal of the cube , You can see the hexagonal shape of the cube . Hexagonal boundaries represent colors , The horizontal axis shows purity , Lightness is measured along the vertical axis .
HSV Color component range
Generally, the effective processing of color space image is in HSV Space goes on , And then for the basic color corresponding to HSV Components need to be given a strict range , The following is the fuzzy range calculated by experiment ( The exact range is not given on the Internet ).
H: 0— 180
S: 0— 255
V: 0— 255
Here, part of red is classified as purple :( stay OpenCv Library functions used in RGB2HSV The switch to HSV After the color model ,H The weight should be in 0~360 Range , That is, the following table H The component value should be multiplied by 2)

HSV Hexagonal pyramid
H Parameters represent color information , That is, the position of the spectral color . This parameter is represented by an angular quantity , red 、 green 、 Blue purity respectively S Is a proportional value , Range from 0 To 1, It is expressed as the ratio between the purity of the selected color and the maximum purity of that color .S=0 when , Only grayscale . Apart, 120 degree . Complementary colors differ from each other 180 degree .
V Indicates the brightness of a color , Range from 0 To 1. There is one caveat : There's no direct relationship between it and light intensity .


1、RGB Convert to HSV The algorithm of :
max=max(R,G,B)
min=min(R,G,B)
V=max(R,G,B)
S=(max-min)/max
ifR = max,H =(G-B)/(max-min)* 60
ifG = max,H = 120+(B-R)/(max-min)* 60
ifB = max,H = 240 +(R-G)/(max-min)* 60
ifH < 0,H = H+ 360
2、HSV Convert to RGB The algorithm of :
if s = 0
R=G=B=V
else
H /= 60;
i = INTEGER(H)
f = H - i
a = V * ( 1 - s )
b = V * ( 1 - s * f )
c = V * ( 1 - s * (1 - f ) )
switch(i)
case 0: R = V; G = c; B = a;
case 1: R = b; G = v; B = a;
case 2: R = a; G = v; B = c;
case 3: R = a; G = b; B = v;
case 4: R = c; G = a; B = v;
case 5: R = v; G = a; B = b;
HSV It is an intuitive color model for users . We can start with a pure color , That is, specify the color angle H, And let V=S=1, Then we can add black and white to it to get the color we need . Increasing black can reduce V and S unchanged , Similarly, increasing white can reduce S and V unchanged . for example , To get dark blue ,V=0.4 S=1 H=240 degree . To get a light blue ,V=1 S=0.4 H=240 degree .
As a general rule , The human eye can distinguish 128 Different colors ,130 Color saturation ,23 A shade . If we use 16Bit Express HSV Words , It can be used 7 To store H,4 To store S,5 To store V, namely 745 perhaps 655 We can meet our needs .
because HSV It is an intuitive color model , Therefore, it is widely used in many image editing tools , Such as Photoshop( stay Photoshop It's called in Chinese HSB) wait , But this also determines that it is not suitable for use in lighting models , Many ray mixing operations 、 Light intensity calculation cannot be used directly HSV To achieve .
边栏推荐
- Qt-5-multi window programming
- Imitation B station web, app, background
- Mr. Ali taught you how to use JMeter for pressure test (detailed drawing)
- Add SSL security certificate to web site
- Solution of difficult and miscellaneous problems in MVN packaging
- STM32F0-DAY1
- Redis学习(3)—— 持久化机制
- Redis learning (3) -- persistence mechanism
- Calculate subtotal of advertising business
- [font multi line display ellipsis] and [dialog box] implementation ----- case explanation, executable code
猜你喜欢

Pyqt environment in pycharm

How can an e-commerce system automatically cancel an order when it times out?
![[Goo Goo donkey takeout rebate system] customer service configuration tutorial of takeout CPS project - (attached with picture and text building tutorial)](/img/54/d30b9c08e46760dac8c3405716941f.jpg)
[Goo Goo donkey takeout rebate system] customer service configuration tutorial of takeout CPS project - (attached with picture and text building tutorial)

Design and implementation of object system in redis

Num in tensorflow basiclstmcell_ What are units- What is num_ units in tensorflow BasicLSTMCell?

Installation of oracle19c under alicloud lightweight application server linux-centos7

Using the path module to prompt errors in ts+vite projects

Chapter 2 - physical layer (I)

Don't know how to interview? Test interview questions summary, teach you to face the interview questions

Record the troubleshooting process of excessive CPU usage
随机推荐
Declare war on uncivilized code II
[googolu] takeout rebate system - business domain name of KFC configuration applet
2021-2022 recall of the final exam questions of non relational database of Shandong University
Installation of MySQL 8.0.19 under alicloud lightweight application server linux-centos7
Summary of the most basic methods of numpy
[test process and theory - test process system]
[untitled] fish pond forwarding command
Qt-2-signal and slot
What is software testing?
Teach you how to design interface automation test cases: extract interface information and analyze it
Qt-3-basic components
Two of my essays
Chapter 2 - physical layer (I)
Configuration of oracle19c under alicloud lightweight application server linux-centos7
Solution of difficult and miscellaneous problems in MVN packaging
Vscade, open a folder or workspace... (file - > open folder) solution
Win10 install tensorflow
MySQL failover and master-slave switchover based on MHA
Qt-3-basic assembly 2
Subshell