def test_haardetector(): """ Excersize the Haar feature detector. Asserts that some basic test cases are correct. """ path = os.path.dirname(__file__) image = plt.imread('%s/../examples/data/cameraman.png' % path) options = {} options['levels'] = 5 options['threshold'] = 0.2 options['locality'] = 5 features = detect(image, HaarDetector, options, debug=True) assert len(features['points'].items()) > 0
def test_haardetector(): """ Asserts that at-least one feature is detected in the "camera-man" image, which should contain many features. """ path = os.path.dirname(__file__) image = plt.imread('{0}/../examples/data/cameraman.png'.format(path)) options = { 'levels': 5, 'threshold': 0.2, 'locality': 5 } features = detector.detect(image, detector.HaarDetector, options) # Asserts that there are features present: assert len(features['points'].items()) > 0
""" Detects haar salient features in an image - """ import scipy.ndimage as nd from matplotlib.pyplot import imread, plot, imshow, show from register.features.detector import detect, HaarDetector # Load the image. image = imread('data/cameraman.png') #image = nd.zoom(image, 0.50) options = {} options['levels'] = 5 # number of wavelet levels options['threshold'] = 0.2 # threshold between 0.0 and 1.0 to filter out weak features (0.0 includes all features) options['locality'] = 5 # minimum (approx) distance between two features features = detect(image, HaarDetector, options) imshow(image, cmap='gray') for id, point in features['points'].items(): plot(point[1], point[0], 'or') show()