Пример #1
0
def test_vmi_find_image_center():

    # BASEX sample image, Gaussians at 10, 15, 20, 70,85, 100, 145, 150, 155
    # image width, height n = 361
    IM = sample_image_dribinski()
    
    # artificially displace center
    IMx = shift(IM, (-1,2))

    # find vertical center
    # radial range limits comparison to smaller radial range
    IMy, offset = find_image_center_by_slice(IMx, radial_range=(10,40), axis=1)

    assert np.allclose(offset, (0,-1), rtol=0, atol=0.1)

    # horizontal center 
    IMy, offset = find_image_center_by_slice(IMx, radial_range=(10,40), axis=0)

    assert np.allclose(offset, (1/2,0), rtol=0, atol=0.1)

    # find both
    IMy, offset = find_image_center_by_slice(IMx, radial_range=(10,40),
                                             axis=(0, 1))

    assert np.allclose(offset, (1/2,-1), rtol=0, atol=0.1)

    # check even image size returns odd
    IM = IM[:-1, 1:]
    m, n = IM.shape

    IMy, offset = find_image_center_by_slice(IM, radial_range=(10,40),
                                             axis=0)

    assert IMy.shape == (m-1, n-1)
Пример #2
0
# image file
filename = 'data/O2-ANU1024.txt.bz2'

# Load as a numpy array
print('Loading ' + filename)
IM = np.loadtxt(filename)
# use plt.imread(filename) to load image formats (.png, .jpg, etc)

rows, cols = IM.shape  # image size

# Image center should be mid-pixel, i.e. odd number of colums
if cols % 2 == 0:
    print("HL: even pixel width image, re-adjust image centre")
    # re-center image based on horizontal and vertical slice profiles
    # covering the radial range [300:400] pixels from the center
    IM = find_image_center_by_slice(IM, radial_range=(300, 400))[0]
    rows, cols = IM.shape  # new image size

c2 = cols // 2  # half-image
print('image size {:d}x{:d}'.format(rows, cols))

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

AIM = iabel_hansenlaw(IM,
                      dr=1,
                      use_quadrants=(True, True, True, True),
                      vertical_symmetry=False,
                      horizontal_symmetry=False,
                      verbose=True)
Пример #3
0
# image file
filename = 'data/O2-ANU1024.txt.bz2'

# Load as a numpy array
print('Loading ' + filename)
IM = np.loadtxt(filename)   
# use plt.imread(filename) to load image formats (.png, .jpg, etc)

rows,cols = IM.shape    # image size

# Image center should be mid-pixel, i.e. odd number of colums
if cols%2 == 0: 
   print ("HL: even pixel width image, re-adjust image centre")
   # re-center image based on horizontal and vertical slice profiles
   # covering the radial range [300:400] pixels from the center
   IM = find_image_center_by_slice (IM, radial_range=(300,400))[0]
   rows,cols = IM.shape   # new image size

c2 = cols//2   # half-image
print ('image size {:d}x{:d}'.format(rows,cols))

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

AIM = iabel_hansenlaw(IM, dr=1, use_quadrants=(True,True,True,True),
                                vertical_symmetry=False,
                                horizontal_symmetry=False,
                                verbose=True)

speeds, r = calculate_speeds (AIM)
Пример #4
0
  "hansenlaw"   : iabel_hansenlaw_transform,
  "basex"       : iabel_basex_transform,   
  "three_point" : iabel_three_point_transform, 
}
# sort dictionary 
transforms = collections.OrderedDict(sorted(transforms.items()))
ntrans = np.size(transforms.keys())  # number of transforms


# Image:   O2- VMI 1024x1024 pixel ------------------
IM = np.loadtxt('data/O2-ANU1024.txt.bz2')
# this is even size, all methods except 'onion' require an odd-size

# recenter the image to an odd size

IModd, offset = find_image_center_by_slice (IM, radial_range=(300,400))
np.savetxt("O2-ANU1023.txt", IModd)

h, w = IModd.shape
print ("centered image 'data/O2-ANU2048.txt' shape = {:d}x{:d}".format(h,w))

Q0, Q1, Q2, Q3 = get_image_quadrants (IModd, reorient=True)
Q0fresh = Q0.copy()    # keep clean copy
print ("quadrant shape {}".format(Q0.shape))


# Intensity mask used for intensity normalization
#   quadrant image region of bright pixels 

mask = np.zeros(Q0.shape,dtype=bool)
mask[500:512, 358:365] = True   
Пример #5
0
"onion"       : iabel_onion_transform,
"hansenlaw"   : iabel_hansenlaw_transform,
"basex"       : iabel_basex_transform,
"three_point" : iabel_three_point_transform,
              }
# sort dictionary
transforms = collections.OrderedDict(sorted(transforms.items()))
ntrans = np.size(transforms.keys())  # number of transforms

# Image:   O2- VMI 1024x1024 pixel ------------------
IM = np.loadtxt('data/O2-ANU1024.txt.bz2')
# this is even size, all methods except 'onion' require an odd-size

# recenter the image to an odd size

IModd, offset = find_image_center_by_slice(IM, radial_range=(300, 400))
np.savetxt("O2-ANU1023.txt", IModd)

h, w = IModd.shape
print("centered image 'data/O2-ANU2048.txt' shape = {:d}x{:d}".format(h, w))

Q0, Q1, Q2, Q3 = get_image_quadrants(IModd, reorient=True)
Q0fresh = Q0.copy()  # keep clean copy
print("quadrant shape {}".format(Q0.shape))

# Intensity mask used for intensity normalization
#   quadrant image region of bright pixels

mask = np.zeros(Q0.shape, dtype=bool)
mask[500:512, 358:365] = True