jixiaozhong / RealSR

Real-World Super-Resolution via Kernel Estimation and Noise Injection
Apache License 2.0
740 stars 102 forks source link

Is the 'Noise Injection' not included in codes? #11

Open conson0214 opened 4 years ago

conson0214 commented 4 years ago

I have not found 'Noise Injection' in data codes, is it not included in release codes so far?

ALLinLLM commented 4 years ago

After reading the reference "Image Blind Denoising With Generative Adversarial Network Based Noise Modeling", I guess the Noise Extraction is like this

                    # in your dataloader's getitem() method:
                    # suppose img_GT is the HR image, and img_LQ is the paired LR image
                    min_var = 1e6
                    min_x = 0
                    min_y = 0
                    x = 0
                    y = 0
                    # find the patch who has min variance 
                    for x in range(0, img_GT.shape[0]-LQ_size, 3*LQ_size):
                        for y in range(0, img_GT.shape[1]-LQ_size, 3*LQ_size):
                            # print("patch", x, y)
                            patch = img_GT[x:x+LQ_size, y:y+LQ_size]
                            var = np.var(patch)
                            if var < min_var:
                                min_var = var
                                min_x = x
                                min_y = y
                    min_patch = img_GT[min_x:min_x+LQ_size, min_y:min_y+LQ_size]
                    noise = min_patch - np.mean(min_patch, axis=(0,1))
                    img_LQ  += noise

and I got the result like 图片 left: HR patch; right: HR noise

jixiaozhong commented 4 years ago

13 Noise patch collection is offline.

  1. Add these noise patches (variance is smaller than the threshold) to the noise pool.
  2. Randomly select one and substract its mean value for each channel.
  3. Add it to the LR image when training.