histogram now adapts to image flipping