HSV Color Space

Source: Internet
Author: User
Understand the HSV color space:

The HSV color mode is another popular color mode except the RGB color mode. RGB is widely used in computers, While HSV is used in TV display. It is more in line with people's description of the color (what color (H), how the depth (s), how the brightness (v )). In fact, the saturation in the menu on the TV is S, and the brightness is v.

H: color, color, and color. Such as red, yellow, and foreign red. In the HSV model, the degree is described, where Red is 0 degrees, green is 120 degrees, and blue is 240 degrees. S: saturation, color depth (0-100%) V: tone, purity, color brightness (0-100%) for easy understanding, the following are referred to as H color, s indicates the depth, and V indicates the brightness. For a more in-depth explanation of the concepts of the color phases, tones, and saturation, see Chapter 3 HSV Color Space Model left in Visual C ++ Digital Image Processing Development entry and programming practices: model 1 Model 2 Note: In Model 2, H is the circle angle formed by the color point on the corresponding circular section and the red radius (for H = 0 degrees. V is the distance from the circular section of the color point to the cone vertex. On the top surface, V = 1 vertex v = 0 s is the ratio of the distance from the color point to the center of the circular section to the circle radius. On the cone surface, S = 1, S = 0 Key point at the center of the circle: When S = 1 V = 1, h Represents any color known as solid color; when S = 0, the shortest color, the shortest is described as gray (Gray also has brightness, black and white are also gray), the gray brightness is determined by V, H is meaningless at this time; when V = 0, the color is the shortest, the shortest is described as black. Therefore, H (the shortest color is black) and S (the shortest color is black) are meaningless. The following is a plane consisting of S and V when h = 0 is Red: In this figure, s increases from 0-1 to the right along the horizontal axis. V increases from bottom to top 0-1. When S = 0, that is, the vertical line edge on the left of the rectangle, different shades of gray when V = 0, that is, the horizontal line edge of the rectangle after work, black when S = 0 V = 1, the color is the brightest, but shortest. That is, the upper left corner of the rectangle is white. When S = 1 (S = 0) V = 0, the color is the deepest (shallow), but the shallow, both are black. When S = 1 V = 1, in the upper right corner of the rectangle, the color is red, that is, the relationship between the common RGB (255, 0, 0) HSV and RGB: in hsv: 1. brightness V is the largest value in the RGB value for normalization. That is to say, V = max (R, G, B)/255.0f; from this point we can launch: 1. the RGB value of solid color (S = 1 V = 1) must have at least one 255, because the solid color v = 1, that is, Max (R, G, B) = 255. At the same time, the RGB value cannot have 3 255, because 3 255 is white, as we mentioned above, white is the product for any color H, V = 1 and S = 0. V = 1 S = 0 is not a solid color. 2. This formula also shows that when V = 0, max (R, G, B) = 0, that is, r = G = B = 0, that is, black. 2. The depth S is the ratio of the difference between the maximum and minimum values in RGB to the maximum values. Set rgbmax = max (R, G, B) rgbmin = min (R, G, B) So S = (rgbmax-rgbmin)/(float) rgbmax can be deduced from this formula: 1. the RGB value of solid color (S = 1 V = 1) must have a 0, because when S = 1, rgbmax-rgbmin = rgbmax, that is, rgbmin = 0. This also shows that the white color (RGB (255,255,255) is not a solid color ). 2. when S = 0, rgbmax-rgbmin = 0, that is, r = G = B. At this time, the color is gray to varying degrees (from white to black, the brightness is determined by V, because v = rgbmax * 100/255, the higher the V, the higher the rgbmax = r = G = B, and the brighter the gray )). This can also be seen from the rectangle shown above. 3. the RGB values corresponding to color h can also be displayed. The solid color ranges from RGB (255, 0, ×), RGB (0,255, ×, 0), RGB (, × ), RGB (x, 255, 0, RGB (x, 0,255), RGB (0, x, 255 ). × Represents any value in (0,255. These six parts form a circle. For specific conversions, see the following section. Analyze it with the above rectangular diagram; 1. if you use the color picker (for example, colorpicker provided in the last section) to observe each horizontal line in the above rectangle (H and V remain unchanged, S is left to right 0-1, it can be found that, from right to left, in the same ordinate, RGB changes are from RGB (R, G, B) to RGB (max (R, G, B ), max (R, G, B), max (R, G, B) is gradually approaching. In the end, the leftmost vertex is gray (r = G = B), and the gray brightness is determined by Max (R, G, B. 2. for every vertical line in the rectangle (H and s remain unchanged, V goes down to 0-1), from top to bottom, the RGB value changes from RGB (R, G, B) gradually approaches RGB (, 0) and turns black. This also provides an idea for us to draw the SV palette above. Conversion between HSV and RGB: RGB-> HSV: S = (max-min)/max) * 100/255 v = max * 100/255 HSV-> RGB: A simple instance: see introduction to visual C ++ digital image processing development and programming practices. Go left to Chapter 3. Example colorpicker interface: function: you can use the left-side color palette to convert HSV and RGB values. You can use the preview box at the bottom of the gradient color of S and v values for any RGB color or H value to display the selected color in real time. You can click color Selection at a position in the color palette allows you to capture the color information of the current mouse position and display the color information at any position on the screen. Example code is free download: http://download.csdn.net/detail/wudaijun/5944489

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.