Just spitballing a high-level implementation:
1. Color correct for the CMYK printing process
2. Load image as a pixel matrix
3. Unwrap pixel matrix into a pixel vector
4. Convert the pixel vector to HSV representation
5. Group each pixel into a palette slot by plugging the H/S dimensions into K-means with 32 as the target (ignoring L for clustering to account for scanlines/flicker)
6. For each palette slot, calculate the "true" HSV value by taking the group's median H/S values and the mean V value
7. Convert HSV representation to 12-bit RGB colorspace