Study Dip 69th Day
Reprint please indicate the source of this article:Http://blog.csdn.net/tonyshengtan , out of respect for the work of the author, reprint please indicate the source! Article code is hosted, Welcome to co-development:Https://github.com/Tony-Tan/DIPpro
The opening crap.
Ah ah ah ah ... The office is so messy. Like the market that, said the good to do a quiet handsome man.
Color transformation in color image processing refers to
g(x ,y)=T [F (x ,y)]
which F g The function that returns the result is a vector, T is x , y An operator of F on space.
By the way, HSI is a discontinuous point at 0° and 360°, and a saturation of 0 is not defined by hue.
Today, the introduction of True color images, but also includes multi-channel images, complementary color processing is based on the color ring, the color of the existing colors to 180°, to obtain a new hue, the use of this change do not know, a very general and very common application is the RGB band CMY changes, however, Nothing else seems to have been heard at the moment. Processing to turn the image into a complementary color.
Algorithm principle
The algorithm principle is very simple, find the complementary color, equal bit replacement is good.
The color ring Newton Don invented, there is no mistake, is the apple smashed Newton, have to say, Newton is a master-level character, color ring as follows:
This color ring may not be the Newton's color ring, but this shows that the complementary complement is a color on both ends of a diameter.
For RGB images, the complementary color is the corresponding CMY image
For HSI and HSV images, the H component needs to be rotated accordingly, and the luminance component also needs to be reversed, and the saturation will be the same as the complementary color effect.
Code implementation
voidComplementary_color (C3 *src,c3 *dst,intWidthintHeightintColor_space_type) {Switch(Color_space_type) { CaseColor_space_rgb:rgb2cmy (src, DST, width, height); Break; CaseColor_space_cmy:cmy2rgb (src, DST, width, height); Break; Casecolor_space_hsi:{ for(intI=0; i<width*height;i++) {DoubleH=SRC[I].C1;if(H>=M_PI) Dst[i].c1=h-m_pi;ElseDst[i].c1=m_pi+h; DST[I].C2=SRC[I].C2; dst[i].c3=255.-SRC[I].C3; } Break; } Casecolor_space_hsv:{ for(intI=0; i<width*height;i++) {DoubleH=SRC[I].C1;if(h>=180.0) dst[i].c1=h-180.0;Elsedst[i].c1=180.0+h; DST[I].C2=SRC[I].C2; dst[i].c3=1.0-SRC[I].C3; } Break; }default: Break; }}
Results observed
Original:
Rgb:
Hsi:
Hsv:
Paintbrush:
Summarize
Simple introduction of the simplest color transformation, complementary colors transformation, you can see that HSI,HSV and RGB processing results are somewhat different, and paintbrush processing and I processing are different, do not know what algorithm it uses.
Cond...
Image processing--color transform inverse color processing