yzxing87 / Invertible-ISP

[CVPR2021] Invertible Image Signal Processing
MIT License
338 stars 39 forks source link

How can I get the raw with 4 channels? #6

Closed tututu05 closed 3 years ago

tututu05 commented 3 years ago

A great work! In your works, the predicted raws are results of demosaicing with 3 channels, right? How can I get raw before demosaicing?

yzxing87 commented 3 years ago

Hi, thanks for your interest in our work.

Inverting the bilinear demosaicing process can be quite easy. You just need to keep the pixels at the positions of bayer pattern. For example, the following sample codes may work:

def invert_bilinear_demosaic(bilinear_raw):
    H,W,_ = bilinear_raw.shape 
    raw = np.zeros((H,W))

    raw[0:H:2, 0:W:2] = bilinear_raw[0:H:2, 0:W:2, 0] # R
    raw[0:H:2, 1:W:2] = bilinear_raw[0:H:2, 1:W:2, 1] # G
    raw[1:H:2, 0:W:2] = bilinear_raw[1:H:2, 0:W:2, 1] # G
    raw[1:H:2, 1:W:2] = bilinear_raw[1:H:2, 1:W:2, 2] # B
    return raw
tututu05 commented 3 years ago

Thanks!