hi, I have been trying to generate image patches for a training set but have not succeded yet. The only method i tried is cropping areas of the image and store the cropped images or patches as an array of bytes. The problem is, same patch gets stored thoughout the array, meaning its cropping the same area in the loop and the rectangle is not moving, could some one explain to me why,
Thank You.
heres the code:
MemoryStream stream = new MemoryStream();
int patchcounter = 0;
int imagecounter = 0;
OriginalHiResPa tches = new Byte[f.numImages()][][];
OriginalHiResha sh1 = new byte[f.numImages()][][];
for (int i = 0; i < f.numImages(); i++)
{
OriginalHiResPa tches[imagecounter] = new Byte[patchcounter+1][];
for (int y = 0; y < TrainingSet.ima ges[imagecounter].Height; y ++)
{
for (int x = 0; x < TrainingSet.ima ges[imagecounter].Width; x ++)
{
Bitmap b = new Bitmap(3, 3);
Graphics g = Graphics.FromIm age(b);
g.DrawImage(Tra iningSet.images[imagecounter], new Rectangle(x, y, b.Width, b.Height), new Rectangle(x, y, 3, 3), GraphicsUnit.Pi xel);
b.Save(stream, System.Drawing. Imaging.ImageFo rmat.Bmp);
OriginalHiResPa tches[imagecounter][patchcounter]=stream.ToArray () ;
patchcounter++;
Array.Resize(re f OriginalHiResha sh1[imagecounter],OriginalHiResh ash1[imagecounter].Length+1);
Array.Resize(re f OriginalHiResPa tches[imagecounter],OriginalHiResP atches[imagecounter].Length+1);
numPatches++;
Application.DoE vents();
}
}
patchcounter = 0;
imagecounter++;
}
}