def _test_numpy(dtype_name, nchannels, order='c'): np_img = create_numpy_image(dtype_name, nchannels, order) vital_img = Image(np_img) recast = vital_img.asarray() # asarray always returns 3 channels np_img = np.atleast_3d(np_img) pixel_type_name = vital_img.pixel_type_name() want = map_dtype_name_to_pixel_type(dtype_name) assert pixel_type_name == want, 'want={} but got={}'.format( want, pixel_type_name) if not np.all(np_img == recast): raise AssertionError( 'Failed dtype={}, nchannels={}, order={}'.format( dtype_name, nchannels, order))
def test_getitem_bool(self): img = Image(720, 480, 1, True, Image.PIXEL_BOOL, 1) nose.tools.assert_equal(img.pixel_type_name(), "bool") val1 = img[0, 0] val2 = img[0, 0, 0] nose.tools.assert_equal(val1, val2)
def test_getitem_double(self): img = Image(720, 480, 3, True, Image.PIXEL_FLOAT, 8) nose.tools.assert_equal(img.pixel_type_name(), "double") val1 = img[0, 0] val2 = img[0, 0, 0] nose.tools.assert_equal(val1, val2)
def test_getitem_int32(self): img = Image(720, 480, 3, True, Image.PIXEL_SIGNED, 4) nose.tools.assert_equal(img.pixel_type_name(), "int32") val1 = img[0, 0] val2 = img[0, 0, 0] nose.tools.assert_equal(val1, val2)
def test_getitem_uint8(self): img = Image(720, 480) nose.tools.assert_equal(img.pixel_type_name(), "uint8") val1 = img[0, 0] val2 = img[0, 0, 0] nose.tools.assert_equal(val1, val2)