def calc_diff(frame0, frame1):
    """
    Calculates the difference image between two frames.
    """
    im = frame1 - frame0
    im = im/2./255. # Scaling
    im += 0.5   # Shift the no change to gray value.
    
    return im