hi,
we have written a program in VC++ using arrays .The program is just basic C,but since the array size is too big we are unable to run the program so it is a must to use pointers .We also tried using malloc but it is giving us a lot of errors .Can anybody help us please.....
P.S.: We are using a library called free image so there will be some library functions used for gettin some functions like bits per pixel, height of the image and stuff like that so dont worry about that just help me out in the main program tats just basic C.
// Finding the bits per pixel
WORD bpp = FreeImage_GetBPP(dib);
// Finding width and height of the image
int width = FreeImage_GetWidth(dib);
int height = FreeImage_GetHeight(dib);
int n, b[1024], l, i, j, a[1024][1024],
p[1024],t,muT=0,totvar=0,mut[1024],
w0[1024],w1[1024],m0[1024],m1[1024],
a12[1024],
betvar[1024],e[1024],emax,tmax=0;
n=width*height;
for(l=0;l<=(pow(2,bpp))-1;l++)
{
for(i=0;i<=width-1;i++)
{
for(j=0;j<=height-1;j++)
{
if(a[i][j]==l)
b[l]++;
}
}
printf("%d",&b[l]);
}
for(i=0;i<=(pow(2,bpp))-1;i++)
{
p[i]=b[i]/n;
}
for(i=0;i<=(pow(2,bpp))-1;i++)
{
muT+=i*p[i];
}
for(i=0;i<=(pow(2,bpp))-1;i++)
{
totvar+=pow((i-muT),2)*p[i];
}
for(t=0;t<=(pow(2,bpp))-1;t++)
{
for(i=0;i<=t;i++)
{
mut[i]+=i*p[i];
}
for(i=0;i<=t;i++)
{
w0[i]+=p[i];
}
w1[t]=1-w0[t];
m0[t]=mut[t]/w0[t];
m1[t]=(muT-mut[t])/w1[t];
betvar[t]=w0[t]*w1[t]*pow((m1[t]*m0[t]),2);
e[t]=betvar[t]/totvar;
}
emax=e[0];
for(i=1;i<=(pow(2,bpp))-1;i++)
{
if(e[i]>emax)
{
emax=a12[i];
tmax=i;
}
}
printf("Optimal Threshold=%d",&tmax);