// SISBuffer.cpp: implementation of the CSISBuffer class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "SISBuffer.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// int CSISBuffer::GetVar(int x, int y, int min) { int a= GetPixel(x, y); int mmt; for(int yy= y- 1; yy < y+ 1; yy++) { for(int xx= x- 1; xx < x+ 1; xx++) { mmt= abs((int)GetPixel(xx, yy)- a); if(mmt > min) min= mmt; } } return min; } float CSISBuffer::GetMeanBright() { int bright= 0; int yi, xi; int cnt= 0; for(yi= 0; yi< GetHeight(); yi++) { for(xi= 0; xi < GetWidth(); xi++) { // if(GetPixel(xi, yi) > 40 && GetPixel(xi, yi) < 200) { bright+= GetPixel(xi, yi); cnt++; } } } if(cnt < 1) cnt= 1; return (float)bright/cnt; } void CSISBuffer::AdjustBright(CSISBuffer &buffer) { double ratio= buffer.GetMeanBright()/GetMeanBright(); int yi, xi; int val; for(yi= 0; yi< GetHeight(); yi++) { for(xi= 0; xi < GetWidth(); xi++) { if(GetPixel(xi, yi) > 200) { continue; } if(GetPixel(xi, yi) < 40) { continue; } val= (int)(ratio*GetPixel(xi, yi)); if(val > 255) { val= 255; } SetPixel(xi, yi, (BYTE)val); } } }