def test_resample_downsample_2d(): test1 = cle.push( np.asarray([[0, 0, 2, 2], [0, 0, 2, 2], [1, 1, 4, 4], [1, 1, 4, 4]])) reference = cle.push(np.asarray([[0, 2], [1, 4]])) result = cle.resample(test1, factor_x=0.5, factor_y=0.5) a = cle.pull(result) b = cle.pull(reference) print(a) assert (np.array_equal(a, b))
def test_resample_upsample_3d(): test1 = cle.push(np.asarray([[[0, 2], [1, 4]], [[5, 5], [5, 5]]])) reference = cle.push( np.asarray([[[0, 0, 2, 2], [0, 0, 2, 2], [1, 1, 4, 4], [1, 1, 4, 4]], [[0, 0, 2, 2], [0, 0, 2, 2], [1, 1, 4, 4], [1, 1, 4, 4]], [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]], [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]])) result = cle.resample(test1, factor_x=2, factor_y=2, factor_z=2) a = cle.pull(result) b = cle.pull(reference) print(a) print(b) assert (np.array_equal(a, b))
def test_resample_3d_interpolation_x(): test1 = cle.push(np.asarray([[[0, 2]]])) reference = cle.push(np.asarray([[ [0, 0.5, 1.5, 1.5], ]])) result = cle.resample(test1, factor_x=2, factor_y=1, factor_z=1, linear_interpolation=True) a = cle.pull(result) b = cle.pull(reference) print(a) print(b) assert (np.array_equal(a, b))
height = 1024 depth = 71 voxel_size = [3, 0.6934, 0.6934] #image = np.empty((71, 1024, 512), np.uint16) import beetlesafari as bs img_arr = bs.imread_raw(filename, width, height, depth) import pyclesperanto_prototype as cle print("Shape before resampling: " + str(img_arr.shape)) buffer = cle.push_zyx(img_arr) resampled = cle.resample(buffer, factor_x=voxel_size[2], factor_y=voxel_size[1], factor_z=voxel_size[0]) img_arr = cle.pull_zyx(resampled) print("Shape after resampling: " + str(img_arr.shape)) # print(img_arr) # Start up napari import napari with napari.gui_qt(): viewer = napari.Viewer() viewer.add_image(img_arr, name='Tribolium')