There are a few reasons why Java ImageIO library flattens the colors of JPEG images. Here are some of them:
1) Java ImageIO reads JPEG images as 4-channel RGBA images, which means that the RGB and Alpha channels of the original JPEG image are combined into a single channel. This can cause the colors of the image to go flat/washed-out due to the lack of color contrast.
2) Java ImageIO also increases the Gamma factor of the image, which means that the mid-tones and shadow details become brighter, thus further flattening the colors.
3) Java ImageIO also applies a gamma correction algorithm to the image before it is sent to the graphics card, which affects the contrast levels of the colors. This can cause them to look dull and flat.
Fortunately, there are a few ways to work around this issue and make sure that your images are displayed with their original, vibrant colors. One approach is to use a library like Apache Sanselan that supports 16-bit color depth, as this can provide more accurate color contrast and brightness. Other approaches involve using special gamma-correction algorithms specifically tailored for JPEG images, or using the 11-bit color precision provided by HDRI imaging.
For more information on this issue, you can take a look at this article https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html