Technicalsymposium.com-Free Email Alerts


Enter Your Email :

Important Note:Login & Check Your Email Inbox and Activate Confirmation Link

Subscribe & Get All Fresher Jobs Information & Study Materials PDF and Projects- Free Download

Computer Graphics Book PDF


Computer Graphics Projects


CG Projects PDF



Computer Graphics Source Codings & Projects PDF- Free Download

Computer Graphics Lab Codings-RGB TO HSV COLOR MODELS

#include "math.h"

#define MIN(a,b) (a<b?a:b)

#define MAX(a,b) (a>b?a:b)

#define NO_HUE -1

void rgbtohsv(float r,float g,float b,float *h,float *s,float *v)

{

float max=MAX(r,MAX(g,b)),min=MIN(r,MIN(g,b));

float delta=max-min;

*v=max;

if(max!=0.0)

*s=delta/max;

else

*s=0.0;

if(*s==0.0) *h=NO_HUE;

else

{

if(r==max)

*h=(g-b)/delta;

else if(g==max)

*h=2+(b-r)/delta;

else if(b==max)

*h=4+(r-g)/delta;

*h*=60.0;

if(*h<0)*h+=360.0;

*h/=360.0;

}

printf("H=%f S= %f V=%f",*h,*s,*v); }

void main()

{

float a,b,c,d,e,f;

clrscr();

printf("Enter the RGB and HSV values :");

scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);

rgbtohsv(a,b,c,&d,&e,&f);

getch();

}

Download All C Programming & Study Materials PDF