Hi I want to fill arraylist in c# iteratively.actually I am doing small program in image processing (to remove noise from image) in which I have mask of size 3*3 that mean for each pixel on image it will collect 9 values. for example consider we have image of size 10*10 so total no. of pixels would be 100, now for each pixel it will collect its 9 neighbor value and fill it in array list. code is
for (int ii = 0; ii < img.Width; ii++)
{
for (int jj = 0; jj < img.Height; jj++)
{
if (ii - 1 >= 0 && jj - 1 >= 0)
{
c = img.GetPixel(ii - 1, jj - 1);
mask[0] = Convert.ToInt16(c.R);
}
else
{
mask[0] = 0;
}
if (jj - 1 >= 0 && ii + 1 < img.Width)
{
c = img.GetPixel(ii + 1, jj - 1);
mask[1] = Convert.ToInt16(c.R);
}
else
mask[1] = 0;
if (jj - 1 >= 0)
{
c = img.GetPixel(ii, jj - 1);
mask[2] = Convert.ToInt16(c.R);
}
else
mask[2] = 0;
if (ii + 1 < img.Width)
{
c = img.GetPixel(ii + 1, jj);
mask[3] = Convert.ToInt16(c.R);
}
else
mask[3] = 0;
if (ii - 1 >= 0)
{
c = img.GetPixel(ii - 1, jj);
mask[4] = Convert.ToInt16(c.R);
}
else
mask[4] = 0;
if (ii - 1 >= 0 && jj + 1 < img.Height)
{
c = img.GetPixel(ii - 1, jj + 1);
mask[5] = Convert.ToInt16(c.R);
}
else
mask[5] = 0;
if (jj + 1 < img.Height)
{
c = img.GetPixel(ii, jj + 1);
mask[6] = Convert.ToInt16(c.R);
}
else
mask[6] = 0;
if (ii + 1 < img.Width && jj + 1 < img.Height)
{
c = img.GetPixel(ii + 1, jj + 1);
mask[7] = Convert.ToInt16(c.R);
}
else
mask[7] = 0;
c = img.GetPixel(ii, jj);
mask[8] = Convert.ToInt16(c.R);
}
double[][] collection_input ={
new double[9]{mask[0],mask[1],mask[2],mask[3],mask[4],mask[5],mask[6],mask[7],mask[8]}
};
here I want collection_ input contain 9 value for each pixel in this case it would be 9 value for each pixel total would be 900. plz help me if u know this
[edit]Code block added - OriginalGriff[/edit]