I have a number of images in RGB-format (not created by Matlab) that I need to convert to CMYK.
Is there a simple script to:
read image_in_RGB.jpg (or .png, or, ...)
convert RGB-to-CMYK and then save image_in_CMYK.jpg
Help would be very much appreciated...
PS: I only have the "standard" matlab and none of the toolboxes...
Anyway, the only output format that supports CMYK is tiff. See help of IMWRITE. I found some "generic" conversion formula between RGB and CMYK (both are 0-1 based):
% Black = minimum(1-Red,1-Green,1-Blue)
% Cyan = (1-Red-Black)/(1-Black)
% Magenta = (1-Green-Black)/(1-Black)
% Yellow = (1-Blue-Black)/(1-Black)
Up to you to make the conversion and invoke IMWRITE
Bruno
As far as I am aware, the primary use for CMYK colour space is in printing, and there the main reasons for its use is that Black (key) ink is much cheaper than the 3 sets of coloured ink that you would need to make up the black component; and also because of the poor colourimetric purity of the inks, equal quantities of CYM usually make a muddy brown and not black, so adding an extra black ink significantly improves the rendition of the picture, when printed.
The relationship that Bruno has given is, as he states, only one of the probably infinite number of of transforms. In the print industry they have another parameter which is called the under cover removal UCR) ratio, which represents the amount of black (key) that is to be used to replace equal quantities of CM & Y, thus having no key and having a murky brown image represents a UCR of 0, and the equation that Bruno has provided you is equivelent to a UCR of 1, where the maximum amount of coloured inks are exchanged for black (key). Invariably the value of UCR selected is very ink/printing machine dependent.
Hope that helps
Regards
Dave Robinson
cartoon = imread('cartoon1401_colour.tif');
Output_File_Name = 'cartoon1401_colour_CMYK';
image(cartoon);
axis off
axis equal
axis tight
print('-dtiff','-cmyk','-r600',Output_File_Name);
imfinfo('cartoon1401_colour_CMYK.tif')
I was expecting the output to be CMYK as I specify the '-cmyk' flag, but the info from "imfinfo" says it is still RGB and this is what I don't understand:
ans =
Filename: 'cartoon1401_colour_CMYK.tif'
FileModDate: '15-Sep-2009 07:30:14'
FileSize: 21467516
Format: 'tif'
FormatVersion: []
Width: 4804
Height: 3602
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: [8 8 8]
Compression: 'PackBits'
PhotometricInterpretation: 'RGB'
StripOffsets: [3602x1 double]
SamplesPerPixel: 3
RowsPerStrip: 1
StripByteCounts: [3602x1 double]
XResolution: 600
YResolution: 600
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [255 255 255]
MinSampleValue: 0
Thresholding: 1
ImageDescription: 'MATLAB Handle Graphics'
Mayby, as you say, I should just bite the bullet and buy photoshop... It is a $1000 though :(
Have another word with your publisher - In my experience most printers want the image in the form of 4 monochrome image separations exactly as Paintshop Pro is giving you.
Remember that these separations cannot be viewed in a combined form directly on your monitor which only deals with a three plane image which is based on R,G and B pixels, not a 4 plane image. (You would need some form of display with cyan, magenta and yellow pixels. I believe such monitors are available for specialist applications).
You can simulate the printing press by converting your black (key) plane to equal quantities of cyan, magenta and yellow - then add this to the respective planes, then subtract the result from 1 (if you are working in doubles) or 255 (if you still are in uint8 format), then display as an RGB image. A bit of a long winded operation when Paintshop Pro will recombine your CMYK image back to RGB.