def test_solarize(self): img = np.array([[0, 128, 255], [1, 127, 254], [2, 129, 253]], dtype=np.uint8) img_r = np.array([[0, 127, 0], [1, 127, 1], [2, 126, 2]], dtype=np.uint8) assert_array_equal(mmcv.solarize(img), img_r) img_r = np.array([[0, 127, 0], [1, 128, 1], [2, 126, 2]], dtype=np.uint8) assert_array_equal(mmcv.solarize(img, 100), img_r)
def __call__(self, results): if np.random.rand() > self.prob: return results for key in results.get('img_fields', ['img']): img = results[key] img_solarized = mmcv.solarize(img, thr=self.thr) results[key] = img_solarized.astype(img.dtype) return results