I am very new to image processing. I have a PNG image (read using ImageIO.read()
) that yields BufferedImage.TYPE_CUSTOM
when I call getType()
on it.
BufferedImage bi = ImageIO.read(new URL("file:/C:/samp1.png"));
int type =bi.getType(); //TYPE_CUSTOM for samp1.png
Now I would like to convert it to one of the following models:
The above needs to be done to process the image further using a library that recognises only the above types.
How do I convert from TYPE_CUSTOM
color model to other models?
Any help/pointers would be much appreciated. If there aren't any existing library to do this, any link/post to steps/algorithm would be great.
To create a new CMYK document in Photoshop, go to File > New. In the New Document window, simply switch the color mode to CMYK (Photoshop defaults to RGB). If you're wanting to convert an image from RGB to CMYK, then simply open the image in Photoshop. Then, navigate to Image > Mode > CMYK.
Linear RGB to XYZ For example, if your values are in the range [0, 255], you must first divide each by 255.0. The output XYZ values are in the nominal range [0.0, 1.0]. The XYZ values will be relative to the same reference white as the RGB system.
Three popular color models are: CMYK (Cyan, Magenta, Yellow, Black) RGB (Red, Green, Blue) Lab Color.
There are several established color models used in computer graphics, but the two most common are the RGB model (Red-Green-Blue) for computer display and the CMYK model (Cyan-Magenta-Yellow-blacK) for printing.
Try this:
public static BufferedImage convert(BufferedImage src, int bufImgType) {
BufferedImage img= new BufferedImage(src.getWidth(), src.getHeight(), bufImgType);
Graphics2D g2d= img.createGraphics();
g2d.drawImage(src, 0, 0, null);
g2d.dispose();
return img;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With