コード例 #1
0
ファイル: test_tools.py プロジェクト: stggh/PyAbel
def test_centering_function():
    # ni -> original shape of the data is (ni, ni)
    # n_c  -> the image center is (n_c, n_c)
    # n  -> after the centering function, the array has a shape (n, n)

    for (ni, n_c, n) in [
        (9, 5, 3),
        (9, 5, 4),
    ]:
        arr = np.zeros((ni, ni))

        if n % 2 == 1:
            arr[n_c - 1:n_c + 2, n_c - 1:n_c + 2] = 1
        else:
            arr[n_c - 1:n_c + 1, n_c - 1:n_c + 1] = 1

        res = center_image(arr, (n_c, n_c), n)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}, n={}'.format(ni, n_c, n))
コード例 #2
0
ファイル: test_tools.py プロジェクト: rth/PyAbel
def test_centering_function_shape():
    # ni -> original shape
    # n  -> result of the centering function
    for (ni, n) in [(20, 10), # crop image
                    (20, 11),
                    (4, 10),  # pad image
                    (4, 11)]:
        data = np.zeros((ni, ni))
        res = center_image(data, (ni//2, ni//2), n)
        assert_equal( res.shape, (n, n),
                    'Centering preserves shapes for ni={}, n={}'.format(ni, n))
コード例 #3
0
ファイル: test_tools.py プロジェクト: stggh/PyAbel
def test_centering_function_shape():
    # ni -> original shape
    # n  -> result of the centering function
    for (ni, n) in [
        (20, 10),  # crop image
        (20, 11),
        (4, 10),  # pad image
        (4, 11)
    ]:
        data = np.zeros((ni, ni))
        res = center_image(data, (ni // 2, ni // 2), n)
        assert_equal(
            res.shape, (n, n),
            'Centering preserves shapes for ni={}, n={}'.format(ni, n))
コード例 #4
0
ファイル: test_tools.py プロジェクト: rth/PyAbel
def test_centering_function():
    # ni -> original shape of the data is (ni, ni)
    # n_c  -> the image center is (n_c, n_c)
    # n  -> after the centering function, the array has a shape (n, n)

    for (ni, n_c, n) in [(9, 5, 3),
                         (9, 5, 4),
                         ]:
        arr = np.zeros((ni, ni))

        if n % 2 == 1:
            arr[n_c-1:n_c+2,n_c-1:n_c+2] = 1
        else:
            arr[n_c-1:n_c+1,n_c-1:n_c+1] = 1

        res = center_image(arr, (n_c, n_c), n)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}, n={}'.format(ni, n_c, n))
コード例 #5
0
filename = 'data/Xenon_ATI_VMI_800_nm_649x519.tif'

# Name the output files
name = filename.split('.')[0].split('/')[1]
output_image = name + '_inverse_Abel_transform_HansenLaw.png'
output_text = name + '_speeds_HansenLaw.dat'
output_plot = name + '_comparison_HansenLaw.pdf'

# Step 1: Load an image file as a numpy array
print('Loading ' + filename)
#im = np.loadtxt(filename)
im = plt.imread(filename)
(rows, cols) = np.shape(im)
print('image size {:d}x{:d}'.format(rows, cols))

im = center_image(im, (340, 245), n=rows)

# Step 2: perform the Hansen & Law transform!
print('Performing Hansen and Law inverse Abel transform:')

recon = iabel_hansenlaw(im, verbose=True)
speeds, r = calculate_speeds(recon)

# save the transform in 8-bit format:
scipy.misc.imsave(output_image, recon)

# save the speed distribution
np.savetxt(output_text, speeds)

## Finally, let's plot the data
コード例 #6
0
ファイル: example_hansenlaw_Xe.py プロジェクト: stggh/PyAbel
filename = 'data/Xenon_ATI_VMI_800_nm_649x519.tif'

# Name the output files
name = filename.split('.')[0].split('/')[1]
output_image = name + '_inverse_Abel_transform_HansenLaw.png'
output_text  = name + '_speeds_HansenLaw.dat'
output_plot  = name + '_comparison_HansenLaw.pdf'

# Step 1: Load an image file as a numpy array
print('Loading ' + filename)
#im = np.loadtxt(filename)
im = plt.imread(filename)
(rows,cols) = np.shape(im)
print ('image size {:d}x{:d}'.format(rows,cols))

im = center_image (im, (340,245), n=rows)

# Step 2: perform the Hansen & Law transform!
print('Performing Hansen and Law inverse Abel transform:')

recon = iabel_hansenlaw (im, verbose=True)
speeds, r = calculate_speeds(recon)


# save the transform in 8-bit format:
scipy.misc.imsave(output_image,recon)

# save the speed distribution
np.savetxt(output_text,speeds)

## Finally, let's plot the data