**:
在開發有關bitmap方面的程式時,經常需要將位圖的顏色在rgb和hsv色彩空間之間轉換,該顏色轉換由c++實現:
rgb顏色空間轉換為hsv空間顏色值:
void rgb2hsv(float r, float g, float b, float& h, float& s, float&v)
if( r == max )
h = ( g - b ) / delta; // between yellow & magenta
else if( g == max )
h = 2 + ( b - r ) / delta; // between cyan & yellow
else
h = 4 + ( r - g ) / delta; // between magenta & cyan
h *= 60; // degrees
if( h < 0 )
h += 360;
}hsv顏色空間轉換為rgb空間顏色值:
void hsv2rgb(float h, float s, float v, float &r, float &g, float &b)
h /= 60; // sector 0 to 5
i = floor( h );
f = h - i; // factorial part of h
p = v * ( 1 - s );
q = v * ( 1 - s * f );
t = v * ( 1 - s * ( 1 - f ) );
switch( i ) }
RGB HSV色彩空間模式的互相轉換
rgb hsv色彩空間模式的互相轉換 rgb顏色空間轉換為hsv空間顏色值 void rgb2hsv float r,float g,float b,float h,float s,float v if r max h g b delta between yellow magenta else if...
色彩空間的轉換
彩圖與灰度圖的相互轉換 rgb gray rgb a gray y 0.212671 r 0.715160 g 0.072169 b gray rgb a r y g y b y a 0 rgb xyz x 0.412411 0.357585 0.180454 r y 0.212649 0.7151...
色彩空間轉換
rgb轉換為yuv void rgb2yuv double r,double g,double b,double y,double u,double v yuv轉換為rgb void yuv2rgb double y,double u,double v,double r,double g,doubl...