find the intensity of the color present in an image especially CYAN, MAGENTA, YELLOW

i want to find the intensity of color present in an image mainly the CYAN, MAGENTA, YELLOW(out of these colors which color in majorly present in image hopefully in percentage), help me with a way (or method)to find those. image is in tif format

5 Comments

What do you define as Cyan, Magenta and Yellow?
E.g. in the following image, what is Cyan?
How are you defining 'intensity of color'? Pure cyan always has the same intensity.
i just wanted to identify the color present in an image and analyse the majority color present in that image.
histogram analysis would be the best way to do that. Unless you know that the image represents data that you would expect to give specific colours you will usually get many minor variations around each pure colour and very few pure cyan pixels or any other non-Black, non-White specific RGB colour.

Sign in to comment.

 Accepted Answer

Very important: Images that you see on a computer screen use the RGB colour model. There is no definition of Cyan, Magenta and Yellow in that colour model. RGB is an additive colour model. Images for printing may use the CMYK colour model. This is a subtractive colour model. Both colour models are device dependent and converting between one and the other requires knowing the colorimetry of each device. Moreover the two models do not cover the same gamut so some colours can be represented in one model but not the other.
The fact that you haven't really answered the question in the comments to your question would indicate that you do not understand what colour models are. If you did, you probably wouldn't even asked your question.
However, a TIFF image can store an image already converted to the cmyk colour model for a specific device. You can see if your image is using the cmyk model with imfinfo, ColorType will be 'CMYK'. If it is the case, then:
img_cmyk = imread(yourtiffile);
cyan = img_cmyk(:, :, 1);
magenta = img_cmyk(:, :, 2);
yellow = img_cmyk(:, :, 3);
black = img_cmyk(:, :, 4);
If however the ColorType returned by imfinfo is 'RGB', then you'll have to follow the process outlined in this help page to convert between the two models. this requires that you have colorimetry information for both the source and destination device.
edit: Went a bit enthusiastic on the colons!

2 Comments

thank you for the post, while i tried those code above its shows error like this
Index exceeds matrix dimensions.
Error in del7 (line 3)
magenta = img_cmyk(:, :, :, 2);
and the image is already converted from rgb-->cmyk by code
I_rgb = imread('org (2).jpg');
inprof = iccread('sRGB.icm');
outprof = iccread('USSheetfedCoated.icc');
C = makecform('icc',inprof,outprof);
I_cmyk = applycform(I_rgb,C);
imwrite(I_cmyk,'org2cmyk.tif','tif')
I've fixed my question. There were extra colons that shouldn't have been there.
But there's no point writing the image just to read it. I_cmyk(:, :, 1) is already the Cyan channel, and so on.
Note that if you use different icc profiles you'll get different values for your cmyk image.

Sign in to comment.

More Answers (0)

Asked:

on 8 Feb 2018

Commented:

on 8 Feb 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!