def test_scale_auto_size():
    source = cle.push(
        np.asarray([[
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
        ]]))

    reference = cle.push(
        np.asarray([[
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 1, 1, 1, 1, 0, 0],
            [0, 0, 0, 0, 1, 1, 1, 1, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        ]]))

    result = cle.scale(source, factor_x=2, factor_y=2, auto_size=True)

    a = cle.pull(result)
    b = cle.pull(reference)

    print(a)
    print(b)

    assert (np.array_equal(a, b))
def test_scale_centered():
    source = cle.push(
        np.asarray([[
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
        ]]))

    reference = cle.push(
        np.asarray([[
            [0, 0, 0, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
        ]]))

    result = cle.scale(source, factor_y=2)

    a = cle.pull(result)
    b = cle.pull(reference)

    print(a)
    print(b)

    assert (np.array_equal(a, b))
Beispiel #3
0
    def get_resampled_image(self, index = None, time_in_seconds = None, resampled_image : cle.Image = None, linear_interpolation : bool = True):
        index, time_in_seconds = self._handle_index_and_time(index, time_in_seconds)

        input_image = cle.push(self.get_image(index))
        voxel_size = self.get_voxel_size_zyx(index)

        resampled_image = cle.scale(input_image, resampled_image, factor_x=voxel_size[2], factor_y=voxel_size[1],
                                       factor_z=voxel_size[0], linear_interpolation=linear_interpolation)

        return resampled_image