- (..)

[1]

., . . . . .: , 1976.

[2]

. . . . .: , 1989.

[3]

., . : 2- . . . .: , 1985.

[4]

Encarnacao J. Einfuerung in die Graphische Datenverarbeiterung// Eurographics '89. Tutorial Notes 1. Hamburg, FRG, September 4-8, 1989. 122 s.

[5]

, . // , N 1, 1989, . 3-8.

[6]

.. // - " " (, 2-10 1983 .). : , 1983, . 16-22.

[7]

: // . ... .: , 1992.

[8]

.. : . .: , 1985.

[9]

/ .., .., .. .: . ... ... : i, 1984. 184 .

[10]

., .. . : / . ... .: , 1991.

[11]

.. . .: , 1988. 288 .

[12]

. . . . .: , 1986.

[13]

., . . . .: , 1980.

[14]

.. . , 1985. 26 . ( ; 607).

[15]

.. . : , 1981. 253 .

[16]

.., .. CGA, EGA, VGA. M.: -, 1992.

[17]

Joseph Hans, Mehl Max. Computer Graphics Hardware: Introduction and State of the Art// Eurographics '91. Tutorial Note 9. Viena, 2.-6. September 1991. Austria, Viena. 29 p.

[18]

Fontenier Guy and Gros Pascal. Architectures of Graphic Processors for Interactive 2D Graphics// Computer Graphics Forum 7 (1988) 78-89.

[19]

Pinkman R., Novak M., Guttag K. Video-RAM exels at fast graphics// Electronics Design, pp. 161-171 (August 18 1983).

[20]

Seidel H.-P. PC Graphics Hardware // Eurographics '88. Tutorial/Cours 8.-Nice, 12.-16. September 1988. France, Nice. 44 p.

[21]

Stralunsfreier Flacbildschirm. MC, Die MikrocomputerZeitschrift. 8, 1989, s. 66.

0.14   1.

RGB HSV RGB HLS , [89] [85]. . , , - R,G,B, (hue), (saturation), (value lightness) .

/*==================================================== RGB_HSV

* HSV RGB

*/

 

#include <stdio.h>

 

#define UNDEFINED -1.0 /* Hue */

0.14.1  V_HSVRGB - HSV RGB

/*--------------------------------------------------- V_HSVRGB

* HSV RGB

*

* void V_HSVRGB (float *r, float *g, float *b,

* float hue, float sat, float val)

*

* :

* 0 <= hue <= 360 - . :

* 0 - , 60 - ,

* 120 - , 180 -

* 240 - , 300 -

*

* 0.0 <= sat <= 1.0 - Saturation -

* 0.0 <= val <= 1.0 - Value -

*

* :

* 0.0 <= r,g,b <= 1.0 - , ,

* V_HSVRGB= 0 -

* 1/2/3 - hue/ sat/ val

*/

 

int V_HSVRGB (r, g, b, hue, sat, val)

float *r, *g, *b, hue, sat, val;

{ int ii, otw;

float c1, c2, c3, fr;

 

otw= 0;

if (sat == 0.0) { /* */

*r= val; *g= val; *b= val;

if (hue != UNDEFINED) ++otw;

} else { /* */

hue-= (ii= (int)(hue/360.0)) * 360.0;

if (ii < 0) hue= -hue;

ii= (int)(hue /= 60.0);

fr= hue - ii;

c1= val*(1.0 - sat);

c2= val*(1.0 - sat*fr);

c3= val*(1.0 - sat*(1.0 - fr));

switch (ii) {

case 0: *r= val; *g= c3; *b= c1; break;

case 1: *r= c2; *g= val; *b= c1; break;

case 2: *r= c1; *g= val; *b= c3; break;

case 3: *r= c1; *g= c2; *b= val; break;

case 4: *r= c3; *g= c1; *b= val; break;

case 5: *r= val; *g= c1; *b= c2; break;

}

}

return (otw);

} /* V_HSVRGB */

0.14.2  V_RGBHSV - RGB HSV

/*--------------------------------------------------- V_RGBHSV

* RGB HSV

*

* void V_RGBHSV (float r, float g, float b,

* float *hue, float *sat, float *val)

*

* :

* 0.0 <= r,g,b <= 1.0 - , ,

*

*

* :

* 0 <= hue <= 360 - . :

* 0 - , 60 - ,

* 120 - , 180 -

* 240 - , 300 -

*

* 0.0 <= sat <= 1.0 - Saturation -

* 0.0 <= val <= 1.0 - Value -

*

* V_RGBHSV= 0 -

* 1/2/3 - r/ g/ b

*/

 

int V_RGBHSV (r, g, b, hue, sat, val)

float r, g, b, *hue, *sat, *val;

{ int otw;

float minc, maxc, h, s, v, dmax, rc, gc, bc;

 

otw= 0;

if (r < 0.0 || r > 1.0) ++otw; /* 頠 */

if (g < 0.0 || g > 1.0) otw= 2;

if (b < 0.0 || b > 1.0) otw= 3;

if (!otw) {

if ((maxc= r) < b) maxc= b; /* */

if (maxc < g) maxc= g;

if ((minc= r) > b) minc= b; /* */

if (minc > g) minc= g;

s= 0.0; /* */

if (maxc != 0.0) s= (maxc-minc)/maxc;

if (s == 0.0) h= UNDEFINED; /* */

else { /* */

dmax= maxc-minc;

rc= (maxc-r)/dmax; /* rc - */

gc= (maxc-g)/dmax; /*  */

bc= (maxc-b)/dmax;

if (r == maxc) h= bc-gc; else /* - */

/* */

if (g == maxc) h= 2+rc-bc; else /* -*/

/* 젠 */

h= 4+gc-rc; /* - */

/* */

if ((h*= 60.0) < 0.0) h+= 360.0;

}

*hue= h; *sat= s; *val= maxc;

}

return (otw);

} /* V_RGBHSV */

0.14.3   V_HSVRGB V_RGBHSV

/*----------------------------------------------- MAIN RGB_HSV

*

* HSV RGB .

*/

 

void main(void)

{ int ii;

float r, g, b, r1, g1, b1, hue, sat, val;

 

r= 0.0; g= 0.0; b= 0.0; hue= 0.0;

 

m0:printf ("HSV r,g,b= (\%f \%f \%f) ? ", r,g,b);

scanf ("\%f\%f\%f", &r, &g, &b);

ii= V_RGBHSV (r, g, b, &hue, &sat, &val);

printf ("V_RGBHSV: otw=\%d hue=\%f sat=\%f val=\%f ",

ii, hue, sat, val);

ii= V_HSVRGB (&r1, &g1, &b1, hue, sat, val);

printf ("V_HSVRGB: otw=\%d r=\%f g=\%f b=\%f ",

ii, r1, g1, b1);

goto m0;

}

 

/*==================================================== RGB_HLS

* HLS RGB

*/

 

#include <stdio.h>

 

#define UNDEFINED -1.0 /* Hue */

0.14.4  V_HLSRGB - HLS RGB

/*--------------------------------------------------- V_HLSRGB

* HLS RGB

*

* void V_HLSRGB (float *r, float *g, float *b,

* float hue, float sat, float lig)

*

* :

* 0 <= hue <= 360 - . :

* 0 - , 60 - ,

* 120 - , 180 -

* 240 - , 300 -

*

* 0.0 <= sat <= 1.0 - Saturation -

* 0.0 <= lig <= 1.0 - Value -

*

* :

* 0.0 <= r,g,b <= 1.0 - , ,

* V_HLSRGB= 0 -

* 1/2/3 - hue/ sat/ lig

*/

 

static float VAL_RGB (n1, n2, hue)

float n1, n2, hue;

{ float otw;

if (hue < 0) hue+= 360.0;

hue= hue - ((int)(hue/360.0)) * 360.0;

if (hue < 60.0) otw= n1+(n2-n1)*hue/60.0; else

if (hue < 180.0) otw= n2; else

if (hue < 240.0) otw= n1+(n2-n1)*(240.0-hue)/60.0; else

otw= n1;

return (otw);

} /* VAL_RGB */

 

int V_HLSRGB (r, g, b, hue, sat, lig)

float *r, *g, *b, hue, sat, lig;

{ int otw;

float m1, m2;

 

otw= 0;

if (sat == 0.0) { /* */

if (hue == UNDEFINED) {

*r= lig; *b= lig; *g= lig;

} else ++otw;

} else { /* */

if ((m2= lig) > 0.5) m2= 1.0 - lig;

m2= lig + sat*m2;

m1= 2*lig - m2;

*r= VAL_RGB (m1, m2, hue+120.0);

*g= VAL_RGB (m1, m2, hue);

*b= VAL_RGB (m1, m2, hue-120.0);

}

return (otw);

} /* V_HLSRGB */

0.14.5  V_RGBHLS - RGB HLS

/*--------------------------------------------------- V_RGBHLS

* RGB HLS

*

* void V_RGBHLS (float r, float g, float b,

* float *hue, float *sat, float *lig)

*

* :

* 0.0 <= r,g,b <= 1.0 - , ,

*

*

* :

* 0 <= hue <= 360 - . :

* 0 - , 60 - ,

* 120 - , 180 -

* 240 - , 300 -

*

* 0.0 <= sat <= 1.0 - Saturation -

* 0.0 <= lig <= 1.0 - Value -

*

* V_RGBHLS= 0 -

* 1/2/3 - r/ g/ b

*/

 

int V_RGBHLS (r, g, b, hue, sat, lig)

float r, g, b, *hue, *sat, *lig;

{ int otw;

float minc, maxc, h, s, l, dm, rc, gc, bc;

 

otw= 0;

if (r < 0.0 || r > 1.0) ++otw;

if (g < 0.0 || g > 1.0) otw= 2;

if (b < 0.0 || b > 1.0) otw= 3;

if (!otw) {

if ((maxc= r) < b) maxc= b;

if (maxc < g) maxc= g;

if ((minc= r) > b) minc= b;

if (minc > g) minc= g;

l= (maxc + minc) / 2; /* */

if (maxc == minc) { /* r=g=b - */

s= 0.0; /* */

h= UNDEFINED;

} else { /* */

dm= maxc-minc;

s= (l < 0.5) ? dm/(maxc+minc) : dm/(2-maxc-minc);

rc= (maxc-r)/dm; /* */

gc= (maxc-g)/dm; /* rc */

bc= (maxc-b)/dm; /*  */

if (r == maxc) h= bc-gc; else /* - */

/* */

if (g == maxc) h= 2+rc-bc; else /* -*/

/* 젠 */

h= 4+gc-rc; /* - */

/* */

if ((h*= 60.0) < 0.0) h+= 360.0;

}

*hue= h; *sat= s; *lig= l;

}

return (otw);

} /* V_RGBHLS */

0.14.6   V_HLSRGB V_RGBHLS

/*----------------------------------------------- MAIN RGB_HLS

*

* HLS RGB .

*/

 

void main(void)

{ int ii;

float r, g, b, r1, g1, b1, hue, sat, lig;

 

r= 0.0; g= 0.0; b= 0.0; hue= 0.0;

 

m1:printf ("HLS r,g,b= (\%f \%f \%f) ? ", r,g,b);

scanf ("\%f\%f\%f", &r, &g, &b);

ii= V_RGBHLS (r, g, b, &hue, &sat, &lig);

printf ("V_RGBHLS: otw=\%d hue=\%f sat=\%f lig=\%f ",

ii, hue, sat, lig);

ii= V_HLSRGB (&r1, &g1, &b1, hue, sat, lig);

printf ("V_HLSRGB: otw=\%d r=\%f g=\%f b=\%f ",

ii, r1, g1, b1);

goto m1;

}

,

 

 

| |