I am developing a robot which paints using an airbrush (3D painting). I intend to use several colors as a CMYK printer, but I do not know how to do the conversion of RGB colors in the computer to the dosage of colors in CMYK.
Professional CMYK conversions use algorithms that use blend matrices and even non-linear warping to fit the RGB color space (which color space? sRGB?) onto available printing inks. The best way to do that might be to find a library that does this, and find the specific parameters for the inks you want to use.
You need to design a system that can deliver an increment in coverage based on an input.
For example, in offset printing and laser printing, the picture is broken up in very small dots (a halftone screen,) and a percentage of dots is covered to achieve a certain degree of saturation. The different colors in 4-color printing are printed using halftone screens at different angles to minimize the case where one colored dot will keep falling right on top of another colored dot and thus "punch out" the covered color.
For an airbrushing robot, perhaps you can measure degree of paint feed (pressure on the lever) and dwell time, and convert that to a measurement of degree of paint coverage. The air brush works a bit like a stochastic paint particle emitter, removing N % of uncovered area within its zone of effect for every millisecond it is "on." The covered area is also a 2D function that's strongest in the center, and fades out towards the edges.
In my opinion, the most interesting programming challenge in this design is figuring out the optimal path to "sweep" the airbrush to get the right amount of coverage of each kind of paint on each area, while not over/under-covering certain areas and making a mess. Holding the airbrush very close, and painting one "pixel" at a time, would work, but wouldn't be very "artistic."
According to rapidtables.com, the following formulae convert [24-bit] RGB color to CMYK:
The R,G,B values are divided by 255 to change the range from 0..255 to 0..1:
R' = R/255
G' = G/255
B' = B/255
The black key (K) color is calculated from the red (R'), green (G') and blue (B') colors:
K = 1-max(R', G', B')
The cyan color (C) is calculated from the red (R') and black (K) colors:
C = (1-R'-K) / (1-K)
The magenta color (M) is calculated from the green (G') and black (K) colors:
M = (1-G'-K) / (1-K)
The yellow color (Y) is calculated from the blue (B') and black (K) colors:
Y = (1-B'-K) / (1-K)
I've wanted to do something similar, so hearing of your experiences would be great.
The best thing I think would be to get a colorimeter, and build a calibration table into your code. Since paint can vary by manufacturer or medium additive (possibly even output levels if the tubes clog some), you could have the robot print its own test pattern. This would also calibrate to the resolution of the color mixer, since you might not have 255 distinct and evenly spaced levels of paint release per color.
Let's say your magenta was stepped with a screw thread attached to a stepper motor. If this thread only had an obscure number of 82 turns to adjust paint release levels, with higher output in the middle of the curve, then the test pattern would show the result of 82 different output levels of your magenta.
Using a colorimeter under diffused ambient lighting, you can determine what colors are output by which flow settings. Then, create a lookup table in your program to do the translation. To increase color resolution, you could even account for premixed colors (shades of brown, green, gray, etc).
Let me know how it goes