# Colourspace Quantisation using Voronoi Diagrams

I don't know if this counts as an objective question, but...

Say I have an image in RGB space $C=[0,1]^3$ and I wanted to resample it to a restricted palette of $P_1,\ldots,P_n\in C$: Would it be appropriate to check which Voronoi cell, generated by the $P$s and bounded by the edges of $C$, a particular colour fell in and then match that to its respective $P_i$?

Clearly generating the Voronoi diagram for the $P$s would be a bit excessive; but if $n$ is relatively small, we could just check which $P_i$ is closest to an arbitrary colour in $C$. That would be pretty efficient.

EDIT It occurred to me that this method could be extended to also dither the image: Check the distances from your colour $x\in C$ to each $P_i$. If $x=P_i$, for some $i$, then we're good; otherwise, calculate the metric $d(x,P_i),\forall i$ and, rather than choose the closest, weight them inverse-proportionally and then "probabilistically" pick one.

For example, restricting to $C=[0,1]$, we have $x=0.1$ and $P_1=0.01$, $P_2=0.3$. Then $\mathbb{P}(x\mapsto P_i) = d(x,P_i)^{-1}\div\sum_{j=1}^nd(x,P_j)^{-1}$; so $\mathbb{P}(x\mapsto P_1)\approx69\%$ and $\mathbb{P}(x\mapsto P_2)\approx31\%$.

• "would it be appropriate" sounds like a modeling question. Isn't the only real answer "it depends on what you want" ? Oct 26, 2013 at 10:00
• Point taken, hence my proviso at the top of the question. I guess what I'm asking, therefore, is: "Is this a known/accepted/standard quantisation method and are there any caveats one should be aware of?" Oct 26, 2013 at 11:01