Skip to content
Snippets Groups Projects
Commit ecfe4a99 authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Set epsilon to meaningfull value, clean up

parent 22898b8b
No related branches found
No related tags found
1 merge request!6Resolve "In painting has different output based on computer OS"
Pipeline #41686 passed
......@@ -62,8 +62,9 @@ def canberra_distance(array1, array2):
def is_close_enough(image1, image2):
"""Checks if the 2 inputs are close enough to pass the test, using different metrics.
The test is considered passed if the difference between the inputs is not more than the a small value for each pixel.
Eg: the first test is considered passed if "distance(image1, image2) < distance(image1, image1 + 2)"
The test is considered passed if the difference between the inputs is not more than the a small value for each
pixel on average.
Eg: the first test is considered passed if "distance(image1, image2) < distance(image1, image1 + epsilon)"
The images are expected to be in unsigned int format (so positive).
......@@ -73,11 +74,13 @@ def is_close_enough(image1, image2):
nb_elements = np.prod(image1.shape)
epsilon = 0.5 # allowed average difference between image
return (
sum_of_squared_absolute_difference(image1, image2) < 2 * nb_elements
and euclidian_distance(image1, image2) < 4 * nb_elements
and manhattan_distance(image1, image2) < 2 * nb_elements
and canberra_distance(image1, image2) < 2 * nb_elements / (np.mean(image1) + np.mean(image2))
sum_of_squared_absolute_difference(image1, image2) < epsilon * nb_elements
and euclidian_distance(image1, image2) < (epsilon ** 2) * nb_elements
and manhattan_distance(image1, image2) < epsilon * nb_elements
and canberra_distance(image1, image2) < epsilon * nb_elements / (np.mean(image1) + np.mean(image2))
)
......@@ -116,18 +119,5 @@ def test_stereo_mapping_and_project():
assert groundtruth_color_image.shape == projected_image.shape
assert groundtruth_map_3d.shape == map_3d.shape
# assert np.allclose(groundtruth_color_image, projected_image)
# assert np.allclose(groundtruth_map_3d, map_3d)
print("ssad", sum_of_squared_absolute_difference(groundtruth_color_image, projected_image))
print("n2", euclidian_distance(groundtruth_color_image, projected_image))
print("manhattan", manhattan_distance(groundtruth_color_image, projected_image))
print("canberra", canberra_distance(groundtruth_color_image, projected_image))
print("ssad", sum_of_squared_absolute_difference(groundtruth_map_3d, map_3d))
print("n2", euclidian_distance(groundtruth_map_3d, map_3d))
print("manhattan", manhattan_distance(groundtruth_map_3d, map_3d))
print("canberra", canberra_distance(groundtruth_map_3d, map_3d))
assert is_close_enough(groundtruth_color_image, projected_image)
assert is_close_enough(groundtruth_map_3d, map_3d)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment