Implement invert and output image functions