谁知道去雾有什么算法
void CMyMenusView::OnProc() {
CDC *pBufferDC, *pDC = GetDC();
pBufferDC = new CDC;
DWORD wh = 512*600*4;
BYTE *pBits = new BYTE[wh], *pBits1 = new BYTE[wh];
// CBitmap *pBmp = pDC->GetCurrentBitmap();
CBitmap *pBmp = new CBitmap;
pBmp->CreateCompatibleBitmap(pDC, 512, 600);
pBufferDC->CreateCompatibleDC(pDC);
pBufferDC->SelectObject(pBmp);
pBufferDC->BitBlt(0, 0, 512, 600, pDC, 0, 0, SRCCOPY);
pBufferDC->GetCurrentBitmap()->GetBitmapBits(wh, pBits);
// pBmp = pDC->GetCurrentBitmap();
DWORD i, j, ij, ij1, ij2, ij3, ij4, ij5, ij6, ij7, ij8, k, t[3];
float s, s1 = 0.2f + 0.04f * m_pApp->m_pSettingDlg->m_Bk;
BYTE p[3];
ZeroMemory(t, sizeof(t));
for (i = 0; i < 600; i ++)
for (j = 1; j < 511; j ++)
for (k = 0; k < 3; k ++)
t[k] += pBits[(i*512 + j) * 4 + k];
for (k = 0; k < 3; k ++)
p[k] = (BYTE)(0.5f * t[k] / wh);
float p3 = 0.5f * (p[0] + p[1] + p[2]);
CopyMemory(pBits1, pBits, wh);
for (i = 1; i < 599; i ++)
{
for (j = 1; j < 511; j ++)
{
ij = (i * 512 + j) * 4;
ij1 = ((i-1) * 512 + j) * 4;
ij2 = ((i+1) * 512 + j) * 4;
ij3 = (i * 512 + j-1) * 4;
ij4 = (i * 512 + j+1) * 4;
ij5 = ((i-1) * 512 + j-1) * 4;
ij6 = ((i+1) * 512 + j-1) * 4;
ij7 = ((i-1) * 512 + j+1) * 4;
ij8 = ((i+1) * 512 + j+1) * 4;
// for (k = 0; k < 3; k ++)
// pBits[ij+k] = (BYTE)(0.2f * pBits[ij+k] + 0.2f * pBits[ij1+k]
// + 0.2f * pBits[ij2+k] + 0.2f * pBits[ij3+k] + 0.2f * pBits[ij4+k]);
for (k = 0; k < 3; k ++)
{
s = 0.15f * pBits[ij1+k] + 0.15f * pBits[ij2+k] + 0.15f * pBits[ij3+k] + 0.15f * pBits[ij4+k]
+ 0.1f * pBits[ij5+k] + 0.1f * pBits[ij6+k] + 0.1f * pBits[ij7+k] + 0.1f * pBits[ij8+k];
s = powf((1.6f * pBits[ij+k] - s - p[k] * s1), 2.f) * s1 / (p3+p[k]);
if (s < 0)
s = 0;
else if (s > 255)
s = 255;
pBits1[ij+k] = (BYTE)s;
}
}
}
这段代码能实现去雾的效果,谁知道它用的是什么方法吗?请帮看看吧!