Ejemplo n.º 1
0
    def test_get_methods(self):

        tmp_arr = np.ones((5, 5), dtype=np.uint8)
        vox = [1.0, 1.0]
        orig = [0, 0]
        img = SpatialImage(tmp_arr)
        metadata = {
            'dim': 2,
            'extent': [5.0, 5.0],
            'shape': (5, 5),
            'type': 'uint8',
            'voxelsize': [1.0, 1.0],
            'origin': [0, 0],
            'max': 1,
            'mean': 1.0,
            'min': 1
        }

        self.assertEqual(img.get_type(), tmp_arr.dtype)
        self.assertEqual(img.get_voxelsize(), vox)
        self.assertEqual(img.get_shape(), tmp_arr.shape)
        self.assertEqual(img.get_origin(), orig)
        self.assertEqual(img.get_extent(),
                         [tmp_arr.shape[0], tmp_arr.shape[1]])
        self.assertEqual(img.get_dim(), 2)
        self.assertDictEqual(img.get_metadata(), metadata)
Ejemplo n.º 2
0
    def test_get_methods(self):

        tmp_arr = np.ones((5,5),dtype=np.uint8)
        vox = [1.0, 1.0]
        orig = [0, 0]
        img = SpatialImage(tmp_arr)
        metadata = {'dim': 2, 'extent': [5.0, 5.0], 'shape': (5, 5), 'type': 'uint8',
                    'voxelsize': [1.0, 1.0], 'origin': [0, 0], 'max': 1, 'mean': 1.0,
                    'min': 1}

        self.assertEqual(img.get_type(), tmp_arr.dtype)
        self.assertEqual(img.get_voxelsize(), vox)
        self.assertEqual(img.get_shape(), tmp_arr.shape)
        self.assertEqual(img.get_origin(), orig)
        self.assertEqual(img.get_extent(), [tmp_arr.shape[0], tmp_arr.shape[1]])
        self.assertEqual(img.get_dim(), 2)
        self.assertDictEqual(img.get_metadata(), metadata)
Ejemplo n.º 3
0
    def __init__(self, sp_img):
        """
        VT_Image constructor

        Parameters
        ----------
        :param *SpatialImage* sp_img: SpatialImage instance --- image and metadata
        """
        if not isinstance(sp_img, SpatialImage):
            print('Warning : sp_img is not a SpatialImage instance')
            sp_img = SpatialImage(sp_img)

        if sp_img.get_dim() == 2:  # 2D management
            sp_img = sp_img.to_3D()

        self._data = sp_img
        self.vt_image = sp_img_to_vt_img(sp_img)
        libvt.VT_AllocArrayImage(pointer(self.vt_image))
Ejemplo n.º 4
0
    def __init__(self, sp_img):
        """
        VT_Image constructor

        Parameters
        ----------
        :param *SpatialImage* sp_img: SpatialImage instance --- image and metadata
        """
        if not isinstance(sp_img, SpatialImage):
            print('Warning : sp_img is not a SpatialImage instance')
            sp_img = SpatialImage(sp_img)

        if sp_img.get_dim()==2: # 2D management
            sp_img = sp_img.to_3D()

        self._data = sp_img
        self.vt_image = sp_img_to_vt_img(sp_img)
        libvt.VT_AllocArrayImage(pointer(self.vt_image))