Hello all,
I would like to start off with stating that i'm not a professional programmer, and often work from examples I find on sites like Code Project. It might be that i'm approaching this from the wrong angle, so please comment as you see fit.
Background
For some analysis purpose I need to calculate the ratio of black vs white pixels of a processed bitmap image. However, not the entire bitmap is of interest. The region of interest varies, therefore I need a photoshop kind of way of selecting (and excluding) different portions of the image.
Approach
The processed bitmap is loaded in a PictureBox derived object and selections are catched through mouse events. The selections are stored in o.a. a rectangle list, which is used to assemble a Graphics.Region object through union and exclude. The region and shapes are visualised by drawing directly into the overrided OnPaint event of the PictureBox object.
So far, so good.
I'm able to access separate pixels in a bitmap by entering unsafe code or through the GetPixel() method and I have a region that represents my pixels of interest. However, I cannot find a way to filter out the pixels that correspond to the selected region.
Is there any way of iterating only through the pixels in my bitmap that correspond with the region?
Any help is greatly appreciated.
Thanks.