LED 의 색좌표 u', v' (CIE1976) 계산 알고리즘

반응형

스펙트로메타를 통해 LED의 스펙트럼 데이타를 추출한 후 색좌표 상의 u',v'(CIE1976) 을 계산하는 알고리즘 입니다. 

table.h
0.02MB

void CIE1976_Chromaticity(double* Wavelength, double* Spectrum,  int Length, double& uPrime, double& vPrime)
{
    double TristimulusX, TristimulusY, TristimulusZ;
    Tristimulus_Value(Wavelength, Spectrum, Length, TristimulusX, TristimulusY, TristimulusZ) ;

    try
    {
        uPrime = (4 * TristimulusX) / (TristimulusX + (TristimulusY * 15) + (TristimulusZ * 3)) ;
        vPrime = (9 *TristimulusY) / (TristimulusX + (TristimulusY * 15) + (TristimulusZ * 3)) ;
    }
    catch(...)
    {
        uPrime = 0 ;
        vPrime = 0 ;
    }
}
//---------------------------------------------------------------------------
void Tristimulus_Value(double* Wavelength, double* Spectrum, int Length, double& TristimulusX, double& TristimulusY, double& TristimulusZ)
{
    double X=0, Y=0, Z=0 ;
    double delta_wavelength = 380 ;
    int index = 0 ;
	
    for(int loop=0 ; loop<Length ; loop++)       // 380nm ~ 830nm 까지의 영역만 계산 ( 1nm 간격 )
    {
        if(Wavelength[loop] > 830) break ;
		
        if(Wavelength[loop] >= delta_wavelength)
        {
            X += (rgb_table[index].Red * Spectrum[loop]) ;
            Y += (rgb_table[index].Green * Spectrum[loop]) ;
            Z += (rgb_table[index].Blue * Spectrum[loop]) ;
			
            index ++ ;
            delta_wavelength += 1 ;    	// 1nm 증가 
        }		
    }	
	
    TristimulusX  = X * K ;
    TristimulusY  = Y * K ;
    TristimulusZ  = Z * K ;	
}
반응형

댓글()