1

I am using skimage to perfom some random noise to my images in order to perform data augmentation, but while im doing it im adding noise to the white background. How could I exclude the background from the computation?

The following lines of code are used for gaussian noise

def save_noisy_image(img, name):
    img = img.view(img.size(0), 3, 180, 180)
    save_image(img, name)

def gaussian_noise():
    for data in dataloader:
        newuuid = str(uuid.uuid4())
        img, _ = data['image'], data['labels']
        gauss_img = torch.tensor(random_noise(img, mode='gaussian', mean=0, var=0.05, clip=True))
        save_noisy_image(gauss_img, "/tmp/tests/"+newuuid+".png")  
        break

gaussian_noise()

Here is an example of a result image

0 Answers0