public struct Pixel : System.ICloneable
{
...
public object Clone()
{
return new Pixel { R = this.R, G = this.G, B = this.B };
}
}
public class Picture : System.ICloneable
{
public object Clone()
{
...
Pixel[,] ClonePixels = new Pixel[Width, Height];
for (uint x = 0; x < Width; x++)
{
for (uint y = 0; y < Height; y++)
{
ClonePixels[x, y] = (Pixel)Pixels[x, y].Clone();
}
}
return new Picture() { Width = this.Width, Height = this.Height, Pixels = ClonePixels };
}
}
public Picture Filtration(Picture originalPicture)
{
Picture picture = (Picture)originalPicture.Clone();
...
}
public Picture Filtration(Picture originalPicture)
{
//Picture picture = (Picture)originalPicture.Clone();
Picture picture = new Picture()
{
Width = originalPicture.Width,
Height = originalPicture.Height,
Pixels = originalPicture.Pixels
};
for (uint x = 0; x < picture.Width; x++)
{
for (uint y = 0; y < picture.Height; y++)
{
double convertedPoint =
0.3 * picture.Pixels[x, y].R
+ 0.59 * picture.Pixels[x, y].G
+ 0.11 * picture.Pixels[x, y].B;
picture.Pixels[x, y].R = convertedPoint;
picture.Pixels[x, y].G = convertedPoint;
picture.Pixels[x, y].B = convertedPoint;
}
}
return picture;
}