0

I'm attempting to do image processing on a screenshot from a iPhone-X, but I'm running into trouble with the red channel not falling into an expected range. The problems are due to the color space of the image bring in DCI-P3 while most of our algorithms were written for the standard sRGB color space of the older iPhones and Android we own.

The area of the screenshot giving us issues has RGB values of r=59, g=125, b=236 when in the DCI-P3 color space. We expect the red channel to be less then 30 and sure enough converting the image via Photoshop's "Edit->Convert To Profile" option results in the specific pixel having a red value of 22.

We're doing this image processing on a Jax-RS webservice so my first attempt at solving the problem was using javax.imageio.ImageIO and friends. Unfortunately, the typical recommendation to covert the image's color space using the below didn't work (red values are still too high):

BufferedImage screenshotCopy = new BufferedImage(screenshot.getWidth(), screenshot.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = screenshotCopy.createGraphics();
g2d.drawImage(screenshot, 0, 0, null);
g2d.dispose();

I've also tried to use Imagemagick, but being new to the tool I've only had some success. Imagemagick can use color spaces for conversion, but when I attempted it the red channel was even higher 70+.

magick convert IMG_0812.PNG -profile ~/Desktop/srgb.icc IMG_0812_converted.PNG

Could someone help me properly convert these color spaces using ImageIO (preferred) or ImageMagick that produces a resulting image similar to Photoshop's "Edit->Convert To Profile" tool?

0

1 Answer 1

2

Can you post a link to your input PNG?

If your input PNG image does not include the DCI-P3 profile, then you need to add that also in your ImageMagick command, which would become:

magick IMG_0812.PNG -profile ~/Desktop/DCI-P3-DCI.icc -profile ~/Desktop/srgb.icc IMG_0812_converted.PNG

or

magick IMG_0812.PNG -profile ~/Desktop/DCI-P3-D65.icc -profile ~/Desktop/srgb.icc IMG_0812_converted.PNG


For DCI-P3 profiles see: http://www.color.org/chardata/rgb/DCIP3.xalter

Note that in ImageMagick 7, magick replaces convert. If you use magick convert, then you will likely be using ImageMagick 6.

1
  • Thank you for clarifying the command. I believe the root cause of my issues was using the incorrect sRGB profile (v4 instead of v2). When I downloaded v2 from color.org it started giving me the correct values. I'm accepting your answer since it will help future validate the correct Imagemagick command for users. Thank you!
    – jstock
    Jun 22, 2018 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.