MLX90640 紅外熱成像儀測(cè)溫模塊開發(fā)筆記(四)損壞和不良像素的處理
	如前“開發(fā)筆記(一)”所說,MLX90640 可能存在不超過 4 個(gè)像素的損壞或者不良像素,在溫度計(jì)算過程完成后,這些不良像素點(diǎn)會(huì)得到錯(cuò)誤的溫度數(shù)據(jù),對(duì)于處理這些不良數(shù)據(jù) MLX 也給出了推薦方法和具體的函數(shù)。(其實(shí)就是找相鄰的正常的溫度數(shù)據(jù)取平均來代替不良數(shù)據(jù))
	
河北穩(wěn)控科技MLX90640 紅外熱成像儀測(cè)溫模塊
	
	前面開發(fā)筆記(一)的內(nèi)容中所說的 API 庫,里面缺少了對(duì)不良像素點(diǎn)的處理函數(shù),在這里補(bǔ)上。
	int CheckAdjacentPixels(uint16_t pix1, uint16_t pix2)
	{
	int pixPosDif;
	pixPosDif = pix1 - pix2;
	if(pixPosDif > -34 && pixPosDif < -30)
	{
	return -6;
	}
	if(pixPosDif > -2 && pixPosDif < 2)
	{
	return -6;
	}
	if(pixPosDif > 30 && pixPosDif < 34)
	{
	return -6;
	}
	return 0;
	}
	float GetMedian(float *values, int n)
	{
	float temp;
	for(int i=0; i{
	for(int j=i+1; j{
	if(values[j] < values[i])
	{
	temp = values[i]; values[i] = values[j]; values[j] = temp;;>;>
	}
	}
	if(n%2==0)
	{
	return ((values[n/2] + values[n/2 - 1]) / 2.0);
	
	}
	else
	{
	}
	
	
	return values[n/2];
	
}
	int IsPixelBad(uint16_t pixel,paramsMLX90640 *params)
	{
	for(int i=0; i<5; i++)
	{
	if(pixel == params->outlierPixels[i] || pixel == params->brokenPixels[i])
	{
	return 1;
	}
	}
	return 0;
	}
	void MLX90640_BadPixelsCorrection(uint16_t *pixels, float *to, int mode, paramsMLX90640
	*params)
	{
	float ap[4]; uint8_t pix; uint8_t line; uint8_t column;
	pix = 0;
	while(pixels[pix] != 0xFFFF)
	{
	line = pixels[pix]>>5;
	column = pixels[pix] - (line<<5);
	if(mode == 1)
	{
	if(line == 0)
	{
	if(column == 0)
	{
	to[pixels[pix]] = to[33];
	}
	else if(column == 31)
	{
	
	}
	else
	{
	}
	}
	to[pixels[pix]] = to[62];
	
	to[pixels[pix]] = (to[pixels[pix]+31] + to[pixels[pix]+33])/2.0;
	else if(line == 23)
	{
	if(column == 0)
	{
	to[pixels[pix]] = to[705];
	}
	else if(column == 31)
	{
	
	}
	else
	{
	}
	}
	to[pixels[pix]] = to[734];
	
	to[pixels[pix]] = (to[pixels[pix]-33] + to[pixels[pix]-31])/2.0;
	else if(column == 0)
	{
	to[pixels[pix]] = (to[pixels[pix]-31] + to[pixels[pix]+33])/2.0;
	}
	else if(column == 31)
	{
	
	}
	else
	{
	to[pixels[pix]] = (to[pixels[pix]-33] + to[pixels[pix]+31])/2.0;
	
	ap[0] = to[pixels[pix]-33];
	ap[1] = to[pixels[pix]-31]; ap[2] = to[pixels[pix]+31]; ap[3] = to[pixels[pix]+33];
	to[pixels[pix]] = GetMedian(ap,4);
	
	}
	else
	{
	}
	
	if(column == 0)
	{
	to[pixels[pix]] = to[pixels[pix]+1];
	}
	else if(column == 1 || column == 30)
	{
	to[pixels[pix]] = (to[pixels[pix]-1]+to[pixels[pix]+1])/2.0;
	}
	else if(column == 31)
	{
	
	}
	else
	{
	0)
	to[pixels[pix]] = to[pixels[pix]-1];
	
	if(IsPixelBad(pixels[pix]-2,params) == 0 && IsPixelBad(pixels[pix]+2,params) ==
	{
	ap[0] = to[pixels[pix]+1] - to[pixels[pix]+2]; ap[1] = to[pixels[pix]-1] - to[pixels[pix]-2];
	if(fabs(ap[0]) > fabs(ap[1]))
	{
	
	
	}
	else
	{
	
	}
	else
	{
	}
	to[pixels[pix]] = to[pixels[pix]-1] + ap[1];
	
	to[pixels[pix]] = to[pixels[pix]+1] + ap[0];
	to[pixels[pix]] = (to[pixels[pix]-1]+to[pixels[pix]+1])/2.0;
	}
	}
	}
	pix = pix + 1;
	}
	}
	用法很簡單,在開發(fā)筆記(三)MLX90640_CalculateTo(Frame, MLXPars, 0.95, Tr, Temp);之后添加兩行即可。如下(斜體是添加的內(nèi)容):
	……
	MLX90640_CalculateTo(Frame, MLXPars, 0.95, Tr, Temp); MLX90640_BadPixelsCorrection(MLXPars.brokenPixels, Temp, 1, MLXPars); MLX90640_BadPixelsCorrection(MLXPars.outlierPixels, Temp, 1, MLXPars);
	……
	/*
	經(jīng)過上面的處理后,Temp 中的損壞和不良像素點(diǎn)已經(jīng)處理,Temp 數(shù)組中是處理完成后的
	768 個(gè)溫度值。
	*/
河北穩(wěn)控科技MLX90640 紅外熱成像儀測(cè)溫成果展示審核編輯:湯梓紅
- 
                                紅外熱成像儀
                                +關(guān)注
關(guān)注
1文章
125瀏覽量
15404 - 
                                測(cè)溫模塊
                                +關(guān)注
關(guān)注
0文章
11瀏覽量
3038 - 
                                MLX90640
                                +關(guān)注
關(guān)注
3文章
22瀏覽量
1649 
發(fā)布評(píng)論請(qǐng)先 登錄
MLX90640紅外成像-紅眼睛相機(jī)(中文資料/開發(fā)筆記/測(cè)試源碼)
RK3288 mlx90640的驅(qū)動(dòng)開發(fā)描述
MLX90640 開發(fā)筆記 成果展示 紅眼睛相機(jī)
MLX90640開發(fā)微型紅外成像儀的優(yōu)勢(shì)與特點(diǎn)
    
紅外熱成像儀測(cè)溫模塊MLX90640開發(fā)筆記(一)
    
MLX90640紅外熱成像傳感器測(cè)溫模塊開發(fā)筆記(二)
    
MLX90640紅外熱成像儀測(cè)溫模塊開發(fā)筆記(五)
    
MLX90640 紅外熱成像儀測(cè)溫傳感器 手機(jī)連接操作詳細(xì)
    
          
        
        
MLX90640紅外熱成像儀測(cè)溫模塊開發(fā)筆記(四)
                
 
    
           
            
            
                
            
評(píng)論