(self, img)
| 63 | |
| 64 | |
| 65 | def __call__(self, img): |
| 66 | |
| 67 | # if random.uniform(0, 1) > self.probability: |
| 68 | # return img |
| 69 | |
| 70 | idx = random.randint(0, 3) |
| 71 | |
| 72 | if idx ==0: |
| 73 | # random select R Channel |
| 74 | img[1, :,:] = img[0,:,:] |
| 75 | img[2, :,:] = img[0,:,:] |
| 76 | elif idx ==1: |
| 77 | # random select B Channel |
| 78 | img[0, :,:] = img[1,:,:] |
| 79 | img[2, :,:] = img[1,:,:] |
| 80 | elif idx ==2: |
| 81 | # random select G Channel |
| 82 | img[0, :,:] = img[2,:,:] |
| 83 | img[1, :,:] = img[2,:,:] |
| 84 | else: |
| 85 | if random.uniform(0, 1) > self.probability: |
| 86 | # return img |
| 87 | img = img |
| 88 | else: |
| 89 | tmp_img = 0.2989 * img[0,:,:] + 0.5870 * img[1,:,:] + 0.1140 * img[2,:,:] |
| 90 | img[0,:,:] = tmp_img |
| 91 | img[1,:,:] = tmp_img |
| 92 | img[2,:,:] = tmp_img |
| 93 | return img |
| 94 | |
| 95 | class ChannelRandomErasing(object): |
| 96 | """ Randomly selects a rectangle region in an image and erases its pixels. |
nothing calls this directly
no outgoing calls
no test coverage detected