[ create a new paste ] login | about

Link: http://codepad.org/bcRWCLD4    [ raw code | output | fork ]

C++, pasted on Apr 18:
void DibThreshold(CDib& dib)
{
	int threshold =0; //current threshold
	int tnew = 128; // new threshold
	long cumtoltal = 0; //current accumulative total
	double m1,m2; // two means

	register int i,j; 

	int w=dib.GetWidth();
	int h=dib.GetHeight();

	BYTE** ptr = dib.GetPtr();
	float hist[256];
	DibHistogram(dib,hist);
	float cdf[256]={0.0,};
	cdf[0]=hist[0];

	for(i=1;i<256;i++)
	{
		cdf[i]=cdf[i-1]+hist[i];

	}

	
	do
	{
		threshold = tnew;
		m1,m2 =0.0;
		for(int i =0;i<threshold;i++)
		{
			m1+= hist[i]*1;
			 m1 /=cdf[threshold-1];
		}

		for(int i =0;i<threshold;i++)
		{
			m2+= hist[i]*1;
			 m2 /=cdf[255];
		}
		 tnew = (int)((m1 + m2) / 2.0);
	}

	
    while (tnew != threshold);
        
    for(i=0;i<w;i++)
	{
		for(j=0;j<h;j++)
		{
			ptr[i][j] = (BYTE)tnew;
		}
	}

}


Output:
1
2
Line 1: error: variable or field 'DibThreshold' declared void
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: