Add SSIM function based on work code from JM