private void calculate(Bitmap bimg)
{
int boundA = 120;
int boundB = 80;
int initi = 0;
int initj = 0;
for (int s = 0; s < 6; s++)
{
for (int i = initi; i < boundA; i++)
{
for (int j = initj; j < boundB; j++)
{
string b = bimg.GetPixel(i, j).B.ToString();
string g = bimg.GetPixel(i, j).B.ToString();
string r = bimg.GetPixel(i, j).B.ToString();
if (b.ToString() == "255" && g.ToString() == "255" && r.ToString() == "255")
{
int tmp = pixCompare[i,j];
if (tmp == 0)
{
differentCount[s] += 1;
pixCompare[i,j] = 1;
}
}
else
{
int tmp = pixCompare[i,j];
if (tmp == 1)
{
differentCount[s] += 1;
pixCompare[i,j] = 0;
}
}
}
}
if (differentCount[s] > 100)
inputNeuron[s] = 1;
else
inputNeuron[s] = 0;
if (boundB < 320)
{
if (boundA < 240)
{
boundB += 80;
initj += 80;
}
else
{
boundB += 80;
initj += 80;
}
}
else
{
if (boundA < 240)
{
boundA += 120;
boundB = 80;
initi += 120;
initj = 0;
}
}
}
}
This is the code for segment comparison that I did.
The video has:
320px width
240px height
the first iteration (s) is for each segments( I am using 4x2 = 8 segments)
the second iteration (i) is for height
the third iteration (j) is for width
I received an exception "Object is currently in use elsewhere." at line "string b = bimg.GetPixel(i, j).B.ToString();"

New Topic/Question
Reply





MultiQuote



|