i'm trying find digit within image. test code took image of digit , used aforge's exhaustive template matching algorithm search in image. think there problem in digit not rectangular whereas image contains is. means there lot of pixels participating in comparison shouldn't be. there way make comparison while ignoring pixels? if not in aforge maybe emgu/opencv or octave?
here's code:
grayscale gray = new grayscalermy(); bitmap template = (bitmap)bitmap.fromfile(@"5template.png"); template = gray.apply(template); bitmap image = (bitmap)bitmap.fromfile(filepath); bitmap sourceimage = gray.apply(image); exhaustivetemplatematching tm = new exhaustivetemplatematching(0.7f); templatematch[] matchings = tm.processimage(sourceimage, template);
as mentioned above in comment, should preprocess data improve matching.
the first thing comes mind morphological opening (erode dilate) reduce background noise
read in image , invert character vectors white:
apply opening smallest possible structuring element/window (3x3):
you try larger structuring elements (5x5):
invert original:
see if helps!
Comments
Post a Comment