No loop required. Just do something like this `mask = (keypoints[:, 0] > kernel_size) & ...; keypoints = keypoints[mask, :]`