Zhaozixiang1228 / MMIF-CDDFuse

[CVPR 2023] Official implementation for "CDDFuse: Correlation-Driven Dual-Branch Feature Decomposition for Multi-Modality Image Fusion."
382 stars 37 forks source link

Some questions about the paper and the code #17

Closed nlilin closed 1 year ago

nlilin commented 1 year ago

Hi, I noticed that your code is trained and tested using single-channel images, but the fusion images in chapter 4 of the paper are color images, if you can describe how to do this in detail, I would be grateful.

matrixgame2018 commented 1 year ago

The following is the solution to your issues

def bgr_to_ycrcb(path):
    one = cv2.imread(path,1)
    one = one.astype('float32')
    (B,G,R) = cv2.split(a)

    Y = 0.299*R + 0.587*G + 0.114*B
    Cr = (R - Y) * 0.713 + 0.5
    Cb = (B - Y) * 0.564 + 0.5

    returns Y, cv2.merge([Cr,Cb])

Through the above code, we can use the Y of YCBCR instead of Gray as the input of the model

I_VIS, CBCR = bgr_to_ycrcb(VIS_files[i])
I_VIS = np.expand_dims(I_VIS,axis=0)/255

in the reasoning stage After we recombine the obtained fi with the above cv2.merge([Cr,Cb]) to get the new YCBCR, convert the new YCBCR to RGB

def ycrcb_to_bgr(1):
    one = one.astype('float32')
    Y, Cr, Cb = cv2.split(1)
    B = (Cb - 0.5) * 1./0.564 + Y
    R = (Cr - 0.5) * 1. / 0.713 + Y
    G = 1./0.587 * (Y - 0.299 * R - 0.114 * B)
    return cv2.merge([B, G, R])
color = ycrcb_to_bgr(cv2.merge([fi,CBCR]))
img_save(color, img_name.split(sep='.')[0], test_out_folder)

Finally, attach the demo of the effect display 01606D_th

nlilin commented 1 year ago

Thank you for your reply.

Zhaozixiang1228 commented 1 year ago

@matrixgame2018 Thank you for your reply. @nlilin Additional details can be found at https://github.com/Zhaozixiang1228/MMIF-CDDFuse/issues/18.