A
So, hier nochmal die Lösung zum Schluß. Ich hab das nun doch noch anders gelöst. Das Problem war das Set/Get Pixel kein Mehrfachzugriff erlaubt weil diese jeweils auf das Bildobjekt zugreifen. Mein Bild wird nun in ein ByteArray gespeichert und ich ändere die Daten direkt im Array. Wie man das ganze macht, wird hier beschrieben: http://ilab.ahemm.org/tutBitmap.html
Das problem der Streifen lag am Mehrfachzugriff auf den Klassifikator und nicht wie vorhher beschrieben. Diesen werde ich noch bearbeiten und bis dahin bleibt die Sperre erstmal drinne.
Für diejenigen die den Beitrag fleißig mitverfolgt haben hier meine Umsetzung:
//Image Locking
BitmapData lockData = i.ImageBitmap.LockBits(new System.Drawing.Rectangle(0, 0, i.ImageBitmap.Width, i.ImageBitmap.Height),
System.Drawing.Imaging.ImageLockMode.ReadWrite,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//Array erstellen um Bild darin zu speichern
Int32[] imageData = new Int32[i.ImageBitmap.Width * i.ImageBitmap.Height];
//benutzen der Marshal Klasse um image data zu kopieren
System.Runtime.InteropServices.Marshal.Copy(lockData.Scan0, imageData, 0, imageData.Length);
int w = i.ImageBitmap.Width;
int h = i.ImageBitmap.Height;
//Dummy erzeugen und anzeigen:
object Sperre = new object();
Parallel.For(0, w, x =>
{
for (ushort y = 0; y < h; y++)
{
{//Laufindex für ByteArray erzeugen, durch X und Y Werte
int j = 0;
if (y == 0)
j = x;
if (y >= 1 && x == 0)
j = w * y;
if (y >= 1 && x >= 0)
j = (w * y) + x;
string l;
lock (Sperre)
{
l = CurrentClassificationPipeline.SelectedClassifier.classify(i.PixelValue(Convert.ToUInt16(x), y));
}
if (Problem.CurrentProblem.Labels.ContainsKey(l))
{
System.Drawing.Color col = Problem.CurrentProblem.Labels[l];
imageData[j] = col.ToArgb();
}
else
imageData[j] = Color.Black.ToArgb();
}
}
});
//Copy Image Data back
Marshal.Copy(imageData, 0, lockData.Scan0, imageData.Length);
//Unlock Image
i.ImageBitmap.UnlockBits(lockData);
System.Drawing.Bitmap res = i.ImageBitmap.Clone(new System.Drawing.Rectangle(0, 0, i.ImageBitmap.Width, i.ImageBitmap.Height),
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Watch.Stop();
MessageBox.Show(Watch.ElapsedMilliseconds.ToString() + " ms");
return res;