def test_cost_functions(): lena = scipy.misc.lena() blurred = scipy.ndimage.gaussian_filter(lena, 3.0) fp = af.FocusPoint(0, 0, 10, 10) stack = np.dstack((lena, blurred)) assert af.discriminate(af.cost_frequencies, stack, fp, 0, 1) == 0 assert af.discriminate(af.cost_sobel, stack, fp, 0, 1) == 0 assert af.discriminate(af.cost_gradient, stack, fp, 0, 1) == 0
def test_discriminator_result(): fp = af.FocusPoint(0, 0, 10, 10) stack = np.random.randn(2 * 100).reshape(10, 10, 2) r = af.discriminate(af.cost_stddev, stack, fp, 0, 1) assert r == 0 or r == 1