1definition of hue, saturation, lightness
Color three-factor (Elementsof color) colors available hue (hue), saturation (purity) and lightness to describe. Any color light seen by the human eye is the combined effect of these three characteristics, which are the three elements of the color, which is directly related to the wavelength of the wave, brightness and saturation and the amplitude of the light wave.
1.1Hue Definition
Color is the sensation caused by the physical light of the object reflecting on the optic nerve of the human eye. The difference in color is determined by the length of the wavelength of the light. As a hue, refers to the situation of these different wavelengths of color. The longest wavelength is red, and the shortest is purple. Red, orange, yellow, green, blue, purple and in their respective red orange, yellow orange, yellow-green, blue-green, blue-violet, red Violet, the 6 kinds of intermediate color-a total of a color as a hue ring. The color arranged on the Hue ring is a high- purity color, known as a solid color. The positions of these colors on the rings are arranged according to the equal spacing of the visual and sensory. A similar method can be used to separate a variety of subtle colors. On the hue ring, the color that is symmetric with the center of the ring and at the position of the location of the dimension is called the complementary color .
1.2definition of saturation
The color is expressed as a color by means of a numerical value or a vivid or distinct degree. There are color of various colors have color value, no color color of the color value of 0, for color color ( purity ) of the high and low, the difference method is based on the degree of gray in this color calculation. Color due to different hues, and even the same hue, because of the difference in brightness, the color will also change.
1.3Definition of lightness
The Brightness and darkness of the expression color is called lightness. The benchmark for calculating lightness is the grayscale test Card. The black is 0, the white is ten, and the interval between the 0-10 is arranged in 9 stages. Color can be divided into color and no color , but the latter still has a lightness. As a color, each color of the respective brightness, the degree of darkness on the gray Test card has a corresponding position value . The color of high color has a great influence on the lightness, and it is not easy to distinguish. It is easier to identify the lightness of color in a bright place, which is difficult to identify in dark places.
2hue, saturation, luminance adjustment
Often in the RGB color space to adjust the brightness and saturation is not very intuitive, and HSL color empty can be very intuitive to represent the saturation and brightness of each pixel. So first read the pixel RGB value of the image and then convert it to the HSL space to get the saturation and luminance values, and then change from the HSL space to the RGB of Space RGB values, the brightness and saturation of the image is adjusted by completing such adjustments for each pixel.
3saturation Adjust the source of the implementation
1#include"highgui.h"2#include"cv.h"3#include"stdio.h"4iplimage* src =0;5 intG_switch_value =0;6 intValue=0;7 intMain ()//int argc,char**argv)8 {9src = cvloadimage ("11.bmp",1);TenCvsize cvsz =cvgetsize (SRC); Oneiplimage* H_plane = cvcreateimage (cvgetsize (SRC),8,1 ); Aiplimage* S_plane = cvcreateimage (cvgetsize (SRC),8,1 ); -iplimage* V_plane = cvcreateimage (cvgetsize (SRC),8,1 ); -Cvcvtcolor (SRC,SRC,CV_RGB2HSV);//RGB to HSV space theCvcvtpixtoplane (Src,h_plane, S_plane, V_plane,0);//HSV is divided into three components of h,s,v -Cvnamedwindow ("src",1); -Cvcreatetrackbar ("Bar","src", &g_switch_value, $, NULL); -UnsignedChar* PTest = (uchar*) s_plane->ImageData; + intM=src->height; - intN=src->width; +printf"%d\n", m);//the length and width of the output image Aprintf"%d\n", n); at while(1) - { - if(Cvgettrackbarpos ("Bar","src")!=value) - { - for(inty=0; y<m;y++) - { in for(intx=0; x<n; X + + ) - { toPtest[y*n+x] +=cvgettrackbarpos ("Bar","src")-value;//Ptest[y*n+x]+g_switch_value; + } - } theValue=cvgettrackbarpos ("Bar","src"); * } $Cvcvtplanetopix (H_plane, S_plane, V_plane,0, SRC);Panax Notoginseng Cvcvtcolor (SRC,SRC,CV_HSV2RGB); -Cvshowimage ("src", SRC); the if(Cvwaitkey ( the)== -) Break;//Press ESC to exit + } ACvreleaseimage (&src); theCvdestroywindow ("src"); + return 0; -}
Hue, saturation, lightness of image processing