Delete 2D unique elements in a 2D NumPy array

Solution 1:

You can use np.where to generate the coordinate pairs that should be removed, and np.unique combined with masking to remove them:

y, x = np.where(image > 0.7)
yx = np.column_stack((y, x))
combo = np.vstack((coordinates, yx))
unique, counts = np.unique(combo, axis=0, return_counts=True)
clean_coords = unique[counts == 1]

The idea here is to stack the original coordinates and the coordinates-to-be-removed in the same array, then drop the ones that occur in both.