Not only using
GetPixel
is prohibitively slow, it's just no serious. If you don't know how to develop image recognition by yourself (this is not easy at all), you can use one of the open-source libraries. I would recommend native .NET library AForge.NET:
http://en.wikipedia.org/wiki/AForge.NET[
^],
http://www.aforgenet.com/[
^].
What you need is the
blob recognition. This is the basic AForge.NET manual with source code sample which you can use to find all the documentation pages:
http://www.aforgenet.com/articles/shape_checker[
^].
The robustness and especially performance of this software is wonderful. For a recognized object, it can give you the
convex hull of it, which is the most characteristic object describing major properties of your blob.
[EDIT]
To find black and white blobs, you need to find the white blobs, then invert the image and find… white blobs again, which will be inverted blacks. See also my comment below: you may need to contrast your source first, using other AForge.NET transformations (always keep your original image).
Please see my past answers with related advise:
How to filter out the unwanted blobs in AForge.net ?[
^],
Convex "Hull" 2d.................................[
^],
blob detection in c#[
^],
Simple BLOB detection algorithm[
^],
image processing using Aforge.net >> I need the help[
^],
(Sorry for some redundancy in answer; I hope you understand that I answered to different people.)
See also:
http://en.wikipedia.org/wiki/Blob_detection[
^].
—SA