基于c++的灰度阈值变换

灰度阈值变换

阈值:又称临界值,在临界范围内使用一种方法,在临界范围外使用另一种方法

y=(x>T)?255:0               T:阈值

LPSTR  lpDIBBits;	//指向源DIB图像的指针
long	lWidth;		//源图像宽度
long	lHeight;	//源图像高度
BYTE	T;			//阈值

//------------------------------

for(int i=0;i<lHeight;i++)
	for(int j=0;j<lWidth;j++)
	{
		lpSrc=(unsighned char *)lpDIBBits+lLineBytes*(lHeight-1-i)+j;//lpDIBBits[i][j]
		if(DB>T)
			*lpSrc=255; 
		else 
			*lpSrc=0;
	}//for_j


你可能感兴趣的:(图像处理,灰度阈值变换)