Loading autocnet/matcher/naive_template.py +2 −3 Original line number Diff line number Diff line Loading @@ -130,12 +130,11 @@ def pattern_match(template, image, upsampling=8, metric=cv2.TM_CCOEFF_NORMED, er # Pad the result array with values outside the valid correlation range width = (np.asarray(u_template.shape) - np.asarray(corrmap.shape)) // 2 print(width) result = np.pad(corrmap, width, mode='constant') # pads zeros if metric == cv2.TM_SQDIFF or metric == cv2.TM_SQDIFF_NORMED: result = np.pad(corrmap, width, mode='constant', constant_values=2) matched_y, matched_x = np.unravel_index(np.argmin(result), result.shape) else: result = np.pad(corrmap, width, mode='constant', constant_values=-2) matched_y, matched_x = np.unravel_index(np.argmax(result), result.shape) # The center of the template is the origin Loading autocnet/matcher/subpixel.py +2 −2 Original line number Diff line number Diff line Loading @@ -289,8 +289,8 @@ def subpixel_template(reference_roi, # These are the inverse of the translation so that the caller can use affine() to # apply the proper translation. Otherwise, the caller would need to use affine.inverse translation_x = -(moving_roi.center[0] - inverse_transformed_affine_center_x) translation_y = -(moving_roi.center[1] - inverse_transformed_affine_center_y) translation_x = -(moving_roi.center[0] - inverse_transformed_affine_center_x) + moving_roi.axr translation_y = -(moving_roi.center[1] - inverse_transformed_affine_center_y) + moving_roi.ayr new_affine = tf.AffineTransform(translation=(translation_x, translation_y)) Loading autocnet/matcher/tests/test_subpixel.py +11 −8 Original line number Diff line number Diff line Loading @@ -66,8 +66,8 @@ def test_prep_subpixel(nmatches, nstrengths): assert arrs[2].shape == (nmatches, nstrengths) assert arrs[0][0] == 0 delta_xs = [0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]# 3.14, -3.14, 4.7, -4.7] delta_ys = [0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]#3.14, -3.14, 4.7, -4.7] delta_xs = [0, 0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]# 3.14, -3.14, 4.7, -4.7] delta_ys = [0, 0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]#3.14, -3.14, 4.7, -4.7] rotation_angles = [0, 2.5, -2.5, -5, 5] #[0, 5]# 2.22, -2.22, 5, -5, 10, -10, 23.68, -23.68] @pytest.mark.parametrize("delta_x", delta_xs) @pytest.mark.parametrize("delta_y", delta_ys) Loading @@ -76,10 +76,13 @@ def test_subpixel_transformed_template(apollo_subsets, delta_x, delta_y, rotatio reference_image = apollo_subsets[0] moving_image = apollo_subsets[0] # The reference image needs to be rotated if the moving image is going to be # artifically rotated and then a match attempted. x = 50 y = 51 x1 = 50 + delta_x y1 = 51 + delta_y x1 = 50 + delta_x #50.25 y1 = 51 + delta_y #50.25 # Artifically rotate the b array by an arbitrary rotation angle. rotated_array, new, (rx1, ry1) = rot(moving_image, (x1, y1), rotation_angle) Loading @@ -105,11 +108,11 @@ def test_subpixel_transformed_template(apollo_subsets, delta_x, delta_y, rotatio new_affine, strength, corrmap = sp.subpixel_template(ref_roi, moving_roi, affine, upsampling=8) new_x, new_y = new_affine((moving_roi._x, moving_roi._y))[0] new_x, new_y = new_affine((moving_roi.x, moving_roi.y))[0] assert pytest.approx(new_x, abs=1/5) == expected[0] assert pytest.approx(new_y, abs=1/5) == expected[1] assert pytest.approx(new_x, abs=1/100) == expected[0] assert pytest.approx(new_y, abs=1/100) == expected[1] def test_estimate_logpolar_transform(iris_pair): Loading autocnet/transformation/roi.py +2 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ class Roi(): # Numpy array in y,x form raster_size = self.data.shape[::-1] # Should this modify (+-) and then round to whole pixel? # what is the extent that can actually be extracted? left_x = self._x - self.size_x right_x = self._x + self.size_x Loading Loading
autocnet/matcher/naive_template.py +2 −3 Original line number Diff line number Diff line Loading @@ -130,12 +130,11 @@ def pattern_match(template, image, upsampling=8, metric=cv2.TM_CCOEFF_NORMED, er # Pad the result array with values outside the valid correlation range width = (np.asarray(u_template.shape) - np.asarray(corrmap.shape)) // 2 print(width) result = np.pad(corrmap, width, mode='constant') # pads zeros if metric == cv2.TM_SQDIFF or metric == cv2.TM_SQDIFF_NORMED: result = np.pad(corrmap, width, mode='constant', constant_values=2) matched_y, matched_x = np.unravel_index(np.argmin(result), result.shape) else: result = np.pad(corrmap, width, mode='constant', constant_values=-2) matched_y, matched_x = np.unravel_index(np.argmax(result), result.shape) # The center of the template is the origin Loading
autocnet/matcher/subpixel.py +2 −2 Original line number Diff line number Diff line Loading @@ -289,8 +289,8 @@ def subpixel_template(reference_roi, # These are the inverse of the translation so that the caller can use affine() to # apply the proper translation. Otherwise, the caller would need to use affine.inverse translation_x = -(moving_roi.center[0] - inverse_transformed_affine_center_x) translation_y = -(moving_roi.center[1] - inverse_transformed_affine_center_y) translation_x = -(moving_roi.center[0] - inverse_transformed_affine_center_x) + moving_roi.axr translation_y = -(moving_roi.center[1] - inverse_transformed_affine_center_y) + moving_roi.ayr new_affine = tf.AffineTransform(translation=(translation_x, translation_y)) Loading
autocnet/matcher/tests/test_subpixel.py +11 −8 Original line number Diff line number Diff line Loading @@ -66,8 +66,8 @@ def test_prep_subpixel(nmatches, nstrengths): assert arrs[2].shape == (nmatches, nstrengths) assert arrs[0][0] == 0 delta_xs = [0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]# 3.14, -3.14, 4.7, -4.7] delta_ys = [0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]#3.14, -3.14, 4.7, -4.7] delta_xs = [0, 0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]# 3.14, -3.14, 4.7, -4.7] delta_ys = [0, 0.25, 1.5, 2.75, -0.25, -1.5, -2.75, 5]#3.14, -3.14, 4.7, -4.7] rotation_angles = [0, 2.5, -2.5, -5, 5] #[0, 5]# 2.22, -2.22, 5, -5, 10, -10, 23.68, -23.68] @pytest.mark.parametrize("delta_x", delta_xs) @pytest.mark.parametrize("delta_y", delta_ys) Loading @@ -76,10 +76,13 @@ def test_subpixel_transformed_template(apollo_subsets, delta_x, delta_y, rotatio reference_image = apollo_subsets[0] moving_image = apollo_subsets[0] # The reference image needs to be rotated if the moving image is going to be # artifically rotated and then a match attempted. x = 50 y = 51 x1 = 50 + delta_x y1 = 51 + delta_y x1 = 50 + delta_x #50.25 y1 = 51 + delta_y #50.25 # Artifically rotate the b array by an arbitrary rotation angle. rotated_array, new, (rx1, ry1) = rot(moving_image, (x1, y1), rotation_angle) Loading @@ -105,11 +108,11 @@ def test_subpixel_transformed_template(apollo_subsets, delta_x, delta_y, rotatio new_affine, strength, corrmap = sp.subpixel_template(ref_roi, moving_roi, affine, upsampling=8) new_x, new_y = new_affine((moving_roi._x, moving_roi._y))[0] new_x, new_y = new_affine((moving_roi.x, moving_roi.y))[0] assert pytest.approx(new_x, abs=1/5) == expected[0] assert pytest.approx(new_y, abs=1/5) == expected[1] assert pytest.approx(new_x, abs=1/100) == expected[0] assert pytest.approx(new_y, abs=1/100) == expected[1] def test_estimate_logpolar_transform(iris_pair): Loading
autocnet/transformation/roi.py +2 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ class Roi(): # Numpy array in y,x form raster_size = self.data.shape[::-1] # Should this modify (+-) and then round to whole pixel? # what is the extent that can actually be extracted? left_x = self._x - self.size_x right_x = self._x + self.size_x Loading