GuoShi28 / CBDNet

Code for "Toward Convolutional Blind Denoising of Real Photographs", CVPR 2019
Apache License 2.0
496 stars 92 forks source link

Question about JPEG compression in generating synthetic noisy image #34

Closed sky135410 closed 4 years ago

sky135410 commented 4 years ago

Thanks for provide the python code of isp process. I do not know which part in the ISP_implement.py correspond to the JPEG compression. .Can you tell me the answer? Very thanks

GuoShi28 commented 4 years ago

I did not add this part in this released code. You can refer to the following code.

        # img_Irgb_convert: input noisy image
        # function: add JPEG compression in noisy image
        max_jpeg = 100
        min_jpeg = 90
        quality_num = random.uniform(min_jpeg, max_jpeg)
        # print(quality_num) 
        encode_param=[int(cv2.IMWRITE_JPEG_QUALITY),quality_num]
        img_Irgb_convert_bgr = self.RGB2BGR(img_Irgb_convert)
        result,encimg = cv2.imencode('.jpg',img_Irgb_convert_bgr*255,encode_param)
        #decode from jpeg format
        decimg_bgr = cv2.imdecode(encimg,1)
        decimg_bgr = decimg_bgr.astype('double') /255
        img_Irgb_convert = self.BGR2RGB(decimg_bgr)
sky135410 commented 4 years ago

Thank you for the solution. I will try this.