Beispiel #1
0
def test_get_in_plane_rotation_correlation(simulations, itf, norim, nortemp):
    image = np.ones((123, 50))
    simulation = simulations[0]
    ang, cor = iutls.get_in_plane_rotation_correlation(
        image,
        simulation,
        intensity_transform_function=itf,
        delta_r=2.6,
        delta_theta=1.3,
        normalize_image=norim,
        normalize_template=nortemp,
    )
    assert ang.shape[0] == 277
    assert cor.shape[0] == 277
Beispiel #2
0
def test_match_image_to_template(mock_sim, rot, dr, dt, nim, nt):
    # serves to actually validate the correctness
    x, y, i = ptutls.get_template_cartesian_coordinates(mock_sim,
                                                        in_plane_angle=rot,
                                                        center=(20, 20))
    # generate an image from the template
    tim = np.zeros((40, 40))
    tim[np.rint(y).astype(np.int32), np.rint(x).astype(np.int32)] = 1.0
    # compare image and template and retrieve the same angle
    a, c = iutls.get_in_plane_rotation_correlation(
        tim,
        mock_sim,
        find_direct_beam=False,
        delta_r=dr,
        delta_theta=dt,
        normalize_image=nim,
        normalize_template=nt,
    )
    assert abs(a[np.argmax(c)] - rot) % 180 < 2.0