def check_simple(self, level=1): a = ImageView(20,20,10,10) b = a.get_transformation_matrix() c = fromCvMat(b) assert_array_almost_equal(c,arrayd(((1,0,0),(0,1,0)))) a = ImageView(100,200,100,100,1,0,True) b = a.get_transformation_matrix() c = fromCvMat(b) assert_array_almost_equal(c,arrayd(((1,0,-50),(0,-1,200))))
def test_project_Haar(self, level=1): input_data = array([[1,2,30,4],[50,6,9,8]],'double') A1 = array([3,-1],'int') ind1 = array([3,0],'int') x = project_Haar(input_data,A1,ind1) assert_array_almost_equal(x,arrayd((11,-26))) A1 = array([5,7,2],'int') ind1 = array([3,1,2],'int') x = project_Haar(input_data,A1,ind1) assert_array_almost_equal(x,arrayd((94,100)))
def check_arrayd(self, level=1): a = rand(1,2,3) self.failUnlessEqual(arrayd(a).dtype,'d') self.failUnlessEqual(arrayd(a.astype('int')).dtype,'d') self.failUnlessEqual(arrayd(a.astype('bool')).dtype,'d')
def check_slide(self, level=1): a = ImageView(angle=pi/2,flip=True) a.slide(0,1) assert_array_almost_equal(a.dparam,arrayd((pi/2,1,1,0))) a.slide(1,-1) assert_array_almost_equal(a.dparam,arrayd((pi/2,1,0,1)))
def check_hard(self, level=1): a = ImageView(1,2,3,4,5,pi/2,True) b = a.get_transformation_matrix() c = fromCvMat(b) assert_array_almost_equal(c,arrayd(((0,0.2,-0.3),(0.2,0,0.4))))
def check_angle(self, level=1): a = ImageView(20,10,0,0,2,pi/2) b = a.get_transformation_matrix() c = fromCvMat(b) assert_array_almost_equal(c,arrayd(((0,0.5,10),(-0.5,0,5))))
def check_scale(self, level=1): a = ImageView(10,20,30,40,2,0) b = a.get_transformation_matrix() c = fromCvMat(b) assert_array_almost_equal(c,arrayd(((0.5,0,-10),(0,0.5,-10))))
def check_make_vi(self, level=1): a = array([[[1,2],[3,4]],[[2,2],[3,4]]],'uint8') b = make_vi(a) assert_array_almost_equal(b,arrayd(((1,3,4,10),(2,4,5,11))))
def check_integral(self, level=1): N = 4 a = arange(N*N,dtype='uint8').reshape(N,N) b = zeros([N,N]) integral(a,b) assert_array_almost_equal(b,arrayd(((0,1,3,6),(4,10,18,28),(12,27,45,66),(24,52,84,120))))