Follow-up on Improving performance… and Genetic Programming: Evolution of Mona Lisa.
I just tested that I can optimize this loop:
unchecked { unsafe { fixed ( Pixel* psourcePixels = sourcePixels ) { Pixel* p1 = (Pixel*)bd.Scan0.ToPointer(); Pixel* p2 = psourcePixels; for ( int i = sourcePixels.Length ; i > 0 ; i--, p1++, p2++ ) { int r = p1->R - p2->R; int g = p1->G - p2->G; int b = p1->B - p2->B; error += r * r + g * g + b * b; } } } }
so that it runs even 60% faster. Don’t dare to tell you how, however.
EDIT: Continued here Ekeforshus
Image may be NSFW.
Clik here to view.

Clik here to view.
