Function to invert pixels' values