View Single Post
Join Date: Dec 2005
Posts: 14
Reputation: manar is an unknown quantity at this point 
Solved Threads: 0
manar manar is offline Offline
Newbie Poster

Re: image manipulation

 
0
  #3
Apr 1st, 2006
hi
thanks for your reply;
i deal with two black and white images(binary images); and want to make correlation method calculations on them to find correlation coefficient.
so the pixel value is (0,0,0) for black or (1,1,1) for white.
that i use the GetPixel then test if its black or white and set an integer to 0 if black or 1 if white.
and then deal with these integer instead of converting the images to array int as you suggest.
this is the code below; its behind the correlation coeff button; I have error when debugging at the bold font:
note: im sure that both images have the same size.
any suggestions...




int q=0;
int w=0;
Bitmap a = (Bitmap)Image.FromFile("C:\\standard\\test1.bmp");
Bitmap b = (Bitmap)Image.FromFile("C:\\standard\\test2.bmp");

int x=0;
int y=0;
int i=0;
int j=0;

for(i=0;i<=a.Height;i++)
{
for(j=0;j<=a.Width;j++)
{
Color c=a.GetPixel(i,j);
Color r=b.GetPixel(i,j);

if (c.R == 0 && c.G == 0 && c.B == 0)
q = 0;
if (c.R == 1 && c.G == 01 && c.B == 1)
q = 1;



if (r.R == 0 && r.G == 0 && r.B == 0)
w = 0;
if (r.R == 1 && r.G == 1 && r.B == 1)
w = 1;

x+=q;
y+=w;
}
}
int s=0;
int ss=0;
int sss=0;


for(i=0;i<=a.Height;i++)
{
for(j=0;j<=a.Width;j++)
{
Color c=a.GetPixel(i,j);
Color r=b.GetPixel(i,j);


if (c.R == 0 && c.G == 0 && c.B == 0)
q = 0;
if (c.R == 1 && c.G == 01 && c.B == 1)
q = 1;



if (r.R == 0 && r.G == 0 && r.B == 0)
w = 0;
if (r.R == 1 && r.G == 1 && r.B == 1)
w = 1;



s+=(q-x)*(q-x);
ss+=(w-y)*(w-y);
}
}

for(i=0;i<=a.Height;i++)
{
for(j=0;j<=a.Width;j++)
{
Color c=a.GetPixel(i,j);
Color r=b.GetPixel(i,j);
if (c.R == 0 && c.G == 0 && c.B == 0)
q = 0;
if (c.R == 1 && c.G == 01 && c.B == 1)
q = 1;



if (r.R == 0 && r.G == 0 && r.B == 0)
w = 0;
if (r.R == 1 && r.G == 1 && r.B == 1)
w = 1;

sss+=(q-x)*(w-y);

}
}
double corr;

corr = sss/(System.Math.Sqrt(((s*s)+(ss*ss))));

label1.Text = corr.ToString();

}
Reply With Quote