pythonmayatiffnuke

Reading 5th TIFF's channel in Python?


I have some TIFF files that are the output of a Maya renderer, and I need to composite them with some real footage. The TIFF files have 5 channels, rgba + depth channel for compositing. However, all the TIFF loading libraries I have tried seem to discard the 5th layer.

Is there a way to load this with the rest of the image?


Solution

  • Use the following approach:

    import cv2
    
    image = cv2.imread('yourImage.tiff', cv2.IMREAD_UNCHANGED)
    print image.shape 
    
    channels = cv2.split(image)
    
    channels[0]  # R channel
    channels[1]  # G channel
    channels[2]  # B channel
    channels[3]  # A channel
    channels[4]  # Z channel
    

    In compositing app like NUKE, you should use a 16-bit or 32-bit OpenEXR file format instead of TIFF. OpenEXR supports up to 1023 render channels what The Foundry NUKE can read in. Read about OpenEXR here.

    Z channel (a.k.a. zDepth) is not ideal for compositing as it brings edge artefacts. Use Deep render pass instead (you can store Deep pass in OpenEXR 2.0 and higher). Read about Z pass artefacts here.

    In EXR files, you can store a variety of AOVs, such as Deep, Normals, Point Positions, UVs, Ambient Occlusion, Shadows, Disparity, Motion Vectors, etc... Read about Deep compositing here.