I am working on an app in which I need to estimate the amount of ink used to print something and corresponding cost. I am not sure if this is the right place to ask this question. If not, please point me that way.
I have per dot cost of the CYMK. Let's say:
I know the RGB value of the dot I am doing to print. So I convert the RGB to CMYK. let's say
(X, Y, Z)(rgb) => (0.5, 0.25, .9, .2)(cmyk)
My question is, If its ok to calculate the cost like following:
total_cost = (0.5 * a) + (0.25 * b) + (0.9 * c) + (0.2 * d)
Please let me if I am missing something.
Your first problem.
There are many ways to convert an RGB file to CMYK. This depends on the color profile and that gives you different CMYK values for the same RGB one. Some give let's say a 300% TAC and other can send a 330%. A color profile is some kind of transformation matrix, and it is not linear.
But not only for the same type of paper. If you use an uncoated paper the total TAC could be around 220%. Different materials suck the ink in different ways.
There are for example some variations on how to generate the same tone. Basically, there is an achromatic or chromatic one. (This paragraph is probably an addendum, this different methods ara not used very often anymore)
You have not only one area, you have percentages of color.
Some pixels will have 100% ink. Some will have 99%, 98%, 97...
Amount of ink is not the same as cost. You need to feed the price base of the ink and compare it to the actual ink used, that also depends on the size of the print. One RGB file can be printed at different sizes.
I must add, this app could be useful. You could add one module for grayscale images or spot colors.
Once upon a time I was tasked to provide data to estimated material costs for photofinishing shops using high speed inkjet print engines. Analyzing ink consumption for tens of thousands of prints of various sizes, for a specific print engine, the average laydown was 0.85 milliliters per square foot total ink. The distribution: Cyan = 26%, Magenta = 24%, Yellow = 22% Kicker (black) 28%. This may or may not fit your circumstances. Let me add, I think a statistical approach is best as contrasted to data assembled for a single print.
This sort of thing is commonly done for commercial printing, both for overall cost calculation and for setting up ink feeds on the press. (there are typically multiple ink feeds across the width of the press, so you can feed more ink to areas that need a lot, and less to those that don't.
However, the printing applications work from the actual separation tint/dot values used by the printing plates - so they'll know the actual CMYK or spot colour values, which simplifies things a lot.
If you're trying to calculate CMYK usage for an RGB image (and I assume you're looking at inkjet prints here, rather than commercial printing), then what you need to know is how the particular printer you're calculating for does its RGB to CMYK conversion. There is no single, fixed, conversion. For example, one of the options you have when converting to CMYK is how much undercolour removal (UCR) or gray component replacement (GCR) to do - for colours with a grey component, you can either make the gray by mixing CMY, or by just using black - or some combination of the two.
If your printer uses ICC profiles to convert from RGB to CMYK, and you have access to those profiles, then using something like littleCMS (a free colour management library) may let you get closer to accurate values.
And you also need to allow for the printer settings - different media or quality settings are likely to use different amounts of ink (which might be handled by using different ICC profiles for the different settings).