色彩空間轉換

2021-08-30 00:14:37 字數 3737 閱讀 3688

//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,

double&b)

//rgb轉換為xyz

void

rgb2xyz(

double

r,double

g,double

bdouble&x,

double&y,

double&z)

else

if(var_g

>

0.04045

)else

if(var_b

>

0.04045

)else

var_r

=var_r

*100.0f

;var_g

=var_g

*100.0f

;var_b

=var_b

*100.0f;//

observer.=2°,illuminant=d65x=

var_r

*0.4124

+var_g

*0.3576

+var_b

*0.1805;y

=var_r

*0.2126

+var_g

*0.7152

+var_b

*0.0722;z

=var_r

*0.0193

+var_g

*0.1192

+var_b

*0.9505;}

//xyz轉換為lab

void

xyz2lab(

double

x,double

y,double

z,double&l,

double&a,

double&b)

else

if(var_y

>

0.008856

)else

if(var_z

>

0.008856

)elsel=

(116

*var_y)-16

;a=500

*(var_x

-var_y);b=

200*

(var_y

-var_z);}//

rgb轉換為lab

void

rgb2lab(

double

r,double

g,double

b,double&l,

double&a,

double&b)

//lab轉換為rgb

void

lab2rgb(

double

l,double

a,double

b,double&r,

double&g,

double&b)

//lab轉換為xyz

void

lab2xyz(

double

lab_l,

double

lab_a,

double

lab_b,

double&x,

double&y,

double&z)

//xyz轉換為rgb

void

xyz2rgb(

double

x,double

y,double

z,double&r,

double&g,

double&b)

//rgb轉換為hsv

void

rgb2hsv(

double

r,double

g,double

b,double&h,

double&s,

double

v)else

//chromaticdata

hsv轉換為rgb

void

hsv2rgb(

double

h,double

s,double

v,double&r,

double&g,

double&b)

else

else

if(var_i==1

)else

if(var_i==2

)else

if(var_i==3

)else

if(var_i==4

)elser=

var_r

*255.0f;//

rgbresultsfrom0to255g=

var_g

*255.0f;b

=var_b

*255.0f;}

}//yuv轉換為xyz

void

yuv2xyz(

double

l,double

u,double

v,double&x,

double&y,

double&z)

//lab轉換為hsv

void

lab2hsv(

double

l,double

a,double

b,double&h,

double&s,

double&v)

//xyz轉換為hsv

void

xyz2hsv(

double

x,double

y,double

z,double&h,

double&s,

double&v)

//rgb轉換為cmy

void

rgb2cmy(

double

r,double

g,double

b,double&c,

double&m,

double

y)//

cmy轉換為rgb

void

cmy2rgb(

double

c,double

m,double

y,double&r,

double&g,

double&b)

//rgb轉換為cmyk

void

rgb2cmyk(

double

r,double

g,double

b,double&c,

double&m,

double

y,double&k)

elsek=

var_k;}//

cmyk轉換為cmy

void

cmyk2cmy(

double

c1,double

m1,double

y1,double

k1,double

&c2,

double

&m2,

double

y2)

色彩空間轉換

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...

色彩空間轉換

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...

色彩空間的轉換

彩圖與灰度圖的相互轉換 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...