I haven't done this stuff in a while.

If I have an image $I$ I can equalize the histogram of the image using some opencv procedure, it's already defined. Equalizing an histogram means essentially to construct a function such that applied to each pixel $p \in I$ the new value it's like it had been sampled from a uniform distribution, assuming gray scale image for such explanation.

I don't remember if what I want to do has a specific name, but I kind of remember it was possible, but suppose I have a gaussian distribution (instead of a uniform one), say $\mathcal{N}(0,\Sigma)$, and I want to re-distribute the colors according to such distribution.

Is there a way to do this in opencv?

  • Where each pixel is 3 Dimensional Random Variable? – Royi May 3 at 7:37
  • Yes, you can consider it like that. – user8469759 May 3 at 7:39
  • Have you seen the answer I wrote? – Royi May 12 at 8:27
  • Yes, but I haven't implemented it yet – user8469759 May 12 at 8:40

After you equalize the histogram you can think of your data as a stream of variables $ {X}_{i} $ where $ X \sim U \left[ 0, 1 \right] $.

Now all you need is to transform samples of Uniform Random Variable into Gaussian Variable.
You should do that by applying the Inverse CDF of Gaussian Distribution.
Basically applying the Inverse Transform Sampling method.
For Normal Distribution easy choice would be the Box Muller Transform.

After you apply this, you can just multiply each RGB pixel in the Cholesky Factorization of $ \Sigma $ to get exactly what you need.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.