I/***********************call RBG to HSI**********************/ int x,y,k; double** hsv = new double*[CAM_WIDTH]; for( x=0;x340 || hsv[x][y]<220){ //if (hsv[x][y]>350 || hsv[x][y]<240){ if (hsv[x][y]>270 || hsv[x][y]<220){ hsv[x][y]=0; } k+=3; } }
/***********************Convert RBG to HSI**********************/ double CHRS_MoleDlg::rgb_to_hsv( int red, int green, int blue ) { double max_, min_, r, g, b, h=0, s=0, v=0; r = (double)red/255.0; g = (double)green/255.0; b = (double)blue/255.0; max_ = max(max( r, g ), b ); min_ = min(min( r, g ), b ); v = max_; if( max_ != 0.0 ) s = (max_-min_)/max_; else s = 0.0; if( s == 0.0 ){ // Do nothing
} else{ double delta = (max_-min_); if( r == max_ ) h = (g-b)/delta; else if( g == max_ ) h = 2.0 + (br)/delta; else if( b == max_ ) h = 4.0 + (rg)/delta; h *= 60.0; while( h<0.0 ) h += 360.0; } double hue = h; int sat = (s * 255.0); int lum = (v * 255.0); return hue; }