'How to determine lower bound pixel value of a gray image using Chebyshev inequality in python-opencv?

I have a theoretical background in probability but I want to implement Chebyshev inequality on any gray image for a better binarization or segmentation. Having known the distribution of the gray image it is possible to find the value k where pixels do not differ more than a certain value from the mean. My questions are as follows:

  1. How to implement Chebyshev's inequality in python-OpenCV?
  2. Is There any public codes that I can implement and hedge around my parameters based on the image statistics? I have seen an implementation of 1D data but it is not clearly explained so it is not easy to follow when implementing 2D and 3D refer this one and this. NB: The nature of my grayscale image is mixed gaussian.

Thank you in advance for any suggestions



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source