예제 #1
0
def test_compare_inverse_symmetrical(array):
    """Check that doing the identity comparison also projects the inverse
    coordinates into the other buffer.
    """
    matcher = FeatureMatcher(array, array)
    matcher.repro_target.from_linear(array.shape)
    matcher.repro_sources.indices.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=1)

    assert (matcher.repro_target.indices !=
            matcher.repro_sources.indices).sum() == 0

    matcher.repro_target.indices.zero_()
    matcher.repro_target.scores.fill_(float("-inf"))
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=1)

    assert (matcher.repro_target.indices !=
            matcher.repro_sources.indices).sum() == 0
예제 #2
0
def test_compare_inverse_asymmetrical(content, style):
    """Check that doing the identity comparison also projects the inverse
    coordinates into the other buffer.
    """

    # Set corner pixel as identical, so it matches 100%.
    content[:, :, -1, -1] = style[:, :, -1, -1]

    matcher = FeatureMatcher(content, style)
    matcher.repro_target.from_linear(style.shape)
    matcher.repro_sources.indices.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=2)

    assert matcher.repro_sources.indices.max() > 0

    matcher.repro_sources.from_linear(content.shape)
    matcher.repro_target.indices.zero_()
    matcher.repro_target.scores.zero_()
    matcher.compare_features_identity()
    matcher.compare_features_inverse(split=2)

    assert matcher.repro_target.indices.max() > 0