public bool PixelMatches(int location, bool initializing) { // TODO: convert this from a method to an abstract class so I can have many different matchers (ie ColorMatchDefinition, Color, Gray Value, etc)...this will be easier after switching from LockBits to EditableBitmap int x; int y; switch (mEdgeAxis) { case Axis.X: x = location; y = pos; break; case Axis.Y: x = pos; y = location; break; default: throw new ArgumentException("Axis not defined alkjdlk"); break; } if (mSearchRecord[x, y] == mSearchMarker) { // optimization... // THIS LOGIC CREATED A BUG: we've already looked at this pixel and it matched...so it must belong to a previous search which terminated because the object was too big...since we ran into it, this object is too big too // BUG DISCOVERED 8/18/08...the previous search could have been terminated because the object was TOO SMALL...it depends how shapes of the blobs and their spacial relationship...ie what about a big blob with a small piece cut off by a mark (e.g. weld) // Possible solution... don't mark the pixels searched immediately, but rather create a list of searched pixels and then mark them only if the blob is too big or runs into the edge of the ROI...might require a BIG list...list needs to be 2D to store X & Y // easiest solution I can think of: if a blob is too small, then clear all markings within it's bounding rectangle abort = true; return(false); // it must match since we've marked it previously, but we don't want to treat it as a find since we're aborting } Color theColor = ownerTool.GetPixelColor(x, y); bool matches = colorMatch.Matches(theColor); if (matches && !initializing) { mSearchRecord[x, y] = mSearchMarker; } return(matches); }