Laplace 算子
Laplace 算子可以卷积模板表示:
// Laplace 算子
// 1. pImageData 图像数据
// 2. nWidth 图像宽度
// 3. nHeight 图像高度
// 4. nWidthStep 图像行大小
BOOL Laplace(unsigned char *pImageData, int nWidth, int nHeight, int nWidthStep)
{
int I = 0;
int j = 0;
int nValue = 0;
unsigned char *pLine[3 = { NULL, NULL, NULL };
for (j = 1; j < nHeight - 1; j++)
{
pLine[0 = pImageData + nWidthStep * (j - 1);
pLine[1 = pImageData + nWidthStep * j;
pLine[2 = pImageData + nWidthStep * (j + 1);
for (I = 1; I < nWidth - 1; i++)
{
nValue =
pLine[0][i + pLine[1][i-1 + pLine[1][i+1 + pLine[2][i -
pLine[1][i * 4;
pLine[0][i-1 = (unsigned char) abs(nValue);
}
}
return TRUE;
}
Laplace 变换效果:
// Laplace 算子
// 1. pImageData 图像数据
// 2. nWidth 图像宽度
// 3. nHeight 图像高度
// 4. nWidthStep 图像行大小
BOOL Laplace(unsigned char *pImageData, int nWidth, int nHeight, int nWidthStep)
{
int I = 0;
int j = 0;
int nValue = 0;
unsigned char *pLine[3 = { NULL, NULL, NULL };
for (j = 1; j < nHeight - 1; j++)
{
pLine[0 = pImageData + nWidthStep * (j - 1);
pLine[1 = pImageData + nWidthStep * j;
pLine[2 = pImageData + nWidthStep * (j + 1);
for (I = 1; I < nWidth - 1; i++)
{
nValue =
pLine[0][i + pLine[1][i-1 + pLine[1][i+1 + pLine[2][i -
pLine[1][i * 4;
pLine[0][i-1 = (unsigned char) abs(nValue);
}
}
return TRUE;
}
Laplace 变换效果: