How can I remap a photo to a limited palette while enforcing fixed color proportions?
Asked 10/5/2014
4 views
2 answers
0
I’m turning a photo into a physical mosaic where each final pixel corresponds to one tile. I have a fixed set of tile colors, and I also have limited quantities of each color, so the final image must use those colors in predetermined proportions (for example, 15% of one color, 3% of another, etc.).
I understand normal palette reduction to a 16-color image, but I specifically need the output image to match a predefined palette and approximate the required percentage of each palette color. What workflow or tools can help with this?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
11y ago
2 Answers
1
Unfortunately, this is not an out-of-the-box solution, but if you have got some programming skills (mostly, the code should be there already and you just need to know how to run or compile it), you might want to look at American Gothic in the palette of Mona Lisa: Rearrange the pixels from the colleagues over at Programming Puzzles & Code Golf.
Your question can be considered a special case of this challenge, instead of providing an "original" picture as the palette, you just can produce a dummy picture containing the right palette with the desired distribution of colours (e.g., if your image has 100 pixels, just create an image with 15 pixels of color #1, 3 pixels of color #2, and so on).
(Note: This only applies to the palette related aspect of the question, but does not address the scaling. There might be potentially different solutions if the scaling is already done with the palette restrictions in mind, but I haven't thought this through properly.)
Originally by user27070. Source · Licensed CC BY-SA 4.0
user27070
11y ago
0
Generated from our catalog & community — verify before relying on it.
Standard indexed-color conversion usually reduces colors, but it does not guarantee exact usage percentages for each palette color. What you need is closer to a constrained color-remapping problem.
A practical approach is to use a custom palette and then remap pixels so the final image matches both:
- your allowed 16 colors, and
- the required count/proportion of each color.
From the suggestions given, Photoshop lookup tables or software that supports a custom output palette may help with the palette-mapping part. However, enforcing exact proportions is generally not an out-of-the-box feature in typical photo editors.
For the proportion constraint, the closest match is a programming/custom-processing solution: create a target palette distribution (for example, a dummy image containing the exact number of pixels for each allowed color), then use a pixel-rearrangement/remapping algorithm to transform the source image into that constrained distribution while preserving the image as well as possible.
So: custom palette tools can handle the color set, but exact weighted proportions will likely require a specialized script or algorithm rather than a standard photo-editing command.
Recommended products
UniqueBot
AI11y ago
Your Answer
Related Questions
What is the process of reducing an image to a fixed set of named colors?
How do I equalize brightness and color across a solar mosaic so it looks like one image?
What is the technique called when you reduce a photo to fewer color levels or colors?
How can I change one specific color in a photo to another color?
Can an in-frame color chart make photos consistent enough for scientific color analysis?