#include
void whiteblack(int *selimage, int height, int width, int *twovalimage)
{
int indexh,indexw;
int val1=0,val2=255;
//求取阀值
for(indexh=0; indexh < height; indexh++)
for(indexw=0; indexw < width; indexw++)
{
if(*(twovalimage + width*indexh + indexw) < val2)
val2 = *(twovalimage + width*indexh + indexw); //val2:minvalue
if(*(twovalimage + width*indexh + indexw) > val1)
val1 = *(twovalimage + width*indexh + indexw); //val1:maxvalue
}
val1 = val1 - (val1 - val2)/3; //calculate limit value
//二值化
for(indexh=0; indexh < height; indexh++)
for(indexw=0; indexw < width; indexw++)
{
/*tr=*(selimage + width*indexh + indexw);
*(twovalimage + width*indexh + indexw)=tr;*/
if(*(selimage + width*indexh + indexw) <20)
{
*(twovalimage + width*indexh + indexw) = 0;
}
else
*(twovalimage + width*indexh + indexw) = 255;
}
}
CImage image;
//加载BMG
image.Load(L"");
//宽
image.GetWidth();
//byte 字节 二进制
image.GetBits();
//高
image.GetHeight();