
Nicolas,
glad I could help !
I'm glad you saw my message! Sorry it took me a day or two to get back into the swing of this project, I was worried you wouldn't see my reply just because I wanted to thank you. The previous one and this one was a huge help.
Actually, you're approach is the good one. I should not have said '1d iterators', its confusing. I only wanted to warn you that according to http://www.boost.org/doc/libs/1_42_0/libs/gil/doc/html/giltutorial.html#OneD... :
Actually, '1d iterators' makes perfect sense now that I understand what you mean (my fault for not understanding earlier). I can definitely see why that would be less efficient. I guess there is a padding to the right and bottom side of the image (I think you graphics guys call it the "stride"?), since by the actual data layout of the image (just an array) you would think the 1d iteration would actually be faster as long as you didn't need to know your exact X/Y coordinate.
Just one comment about your loop, as you mentioned a need for performance, be careful about the order of the loops, as the performance of your traversal may vary with the memory layout of the pixel data of your view. Most of the time, its recommended to iterate over 'y' in the outer loop :
for(int y = 0; y < height, ++x) for(x_iterator x = src.row_begin(x), end = src.row_end(); x != end; ++x) /* ... */
This allows, considering a typical image memory layout, to traverse raw images in a cache coherent way. Note also that calling row_end() at every pixel may not be nicely optimized away by your compiler.
Again, a most excellent tip! I had a bunch with x as the outer loop, I'll switch them over tomorrow, as well as the calling row_end() on every pixel. Thanks again for your help. Developing this small project (a CAPTCHA, if I hadn't mentioned) has been fun with GIL - it's rare I get to do something outside of my normal day-to-day stuff, and this is what makes programming fun. That said, if anybody on this list reading this happens to be in need of a CAPTCHA generator using GIL (I didn't find anything that was already made using C++ and/or GIL), I'd be happy to release my code into the public domain. Some samples of the same word generated a bunch of times is here: http://www.codexterous.com/captchas/ - and it's actually much improved now (more features added, such as the anti-segmentation line is waved). Brett