Ask Your Question

Revision history [back]

How to apply an ICC profile with OpenCV

Is there any way to apply an ICC profile to a Mat image?

Here is an example in Java of what I expect:

import java.awt.RenderingHints;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ConvertIccProfile {

    public static void main(String[] args) throws IOException {
        BufferedImage img = ImageIO.read(new File("test.png"));
        final ICC_Profile ip = ICC_Profile.getInstance("icc/USWebUncoated.icc");
        ColorConvertOp op = new ColorConvertOp(img.getColorModel().getColorSpace(), new ICC_ColorSpace(ip),
            new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY));
        img = op.filter(img, null);
    }

}