www.pudn.com > source.zip > LUV.cpp


#include "gui.h" 
 
void ImageOperations::LUV2(){ 
	int i,j; 
		int R, G, B; 
		unsigned char L1, U, V; 
		 
		double r; 
		double g; 
		double b;		 
		 
		double X; 
		double Y; 
		double Z;		 
		 
		double yr; 
		double L; 
		double eps = 216/24389.; 
		double k = 24389/27.; 
		  
		double Xr = 0.964221;  // reference white D50 
		double Yr = 1.0; 
		double Zr = 0.825211; 
 
		phase = 1; 
		frame->Update(); 
		frame->Refresh(); 
		original = in_image; 
 
		 
		  
		// RGB to XYZ 
		LUV_features = (unsigned char *)malloc(width*height*3*sizeof(unsigned char)); 
		GrayImage = (unsigned char **)malloc(width*sizeof(unsigned char*)); 
		for (i=0; iGetData();   
		for (i=0; i eps ) 
					L =  (double) (116*pow(yr, 1/3.) - 16); 
					 
				else 
					L = k * yr; 
				  
				u = 13*L*(u_ -ur_); 
				v = 13*L*(v_ -vr_); 
		//		Color[0][j][i] = L1; 
		//		Color[1][j][i] = U; 
		//		Color[2][j][i] = V; 
				L1 = (unsigned char) (L*2.55); 
				U = (unsigned char) ((u+134)*0.72033);  
				V = (unsigned char) ((v+140)*0.97328); 
				LUV_features[(i*width*3) + j*3] = L1; 
				GrayImage[j][i] = L1; 
				LUV_features[(i*width*3) + j*3+1] = U; 
				LUV_features[(i*width*3) + j*3+2] = V; 
				Color[0][j][i] = L1; 
				Color[1][j][i] = U; 
				Color[2][j][i] = V; 
				 
			} 
		}	  
		 
}