Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Wikipedia has a nice explanation of <a href="http://en.wikipedia.org/wiki/Standard_deviation#Definition_of_population_values" rel="noreferrer">standard deviation</a>, which you can use to for a standard deviation filter.</p> <p>Basically, it boils down to blurring the image with a box filter, blurring the square of the image with a box filter, and taking the square root of their difference.</p> <p><strong>UPDATE:</strong> This is probably better shown with the equation from Wikipedia... <img src="https://i.stack.imgur.com/RUFQj.png" alt="enter image description here"></p> <p>You can think of the OpenCV <code>blur</code> function as representing the <a href="http://en.wikipedia.org/wiki/Expected_value" rel="noreferrer">expected value</a> (i.e., E[X] a.k.a. the sample mean) of the neighborhood of interest. The random samples X in this case are represented by image pixels in the local neighborhood. Therefore, by using the above equivalence we have something like <code>sqrt(blur(img^2) - blur(img)^2)</code> in OpenCV. Doing it this way allows you to compute the local means and standard deviations.</p> <p>Also, just in case you are curious about the mathematical proof. This equivalence is known as the <a href="http://en.wikipedia.org/wiki/Computational_formula_for_the_variance" rel="noreferrer">computational formula for variance</a>.</p> <p>Here is how you can do this in OpenCV:</p> <pre><code>#include &lt;iostream&gt; #include &lt;opencv2/core/core.hpp&gt; #include &lt;opencv2/highgui/highgui.hpp&gt; #include &lt;opencv2/imgproc/imgproc.hpp&gt; using namespace std; using namespace cv; Mat mat2gray(const Mat&amp; src) { Mat dst; normalize(src, dst, 0.0, 1.0, NORM_MINMAX); return dst; } int main() { Mat image = imread("coke-can.jpg", 0); Mat image32f; image.convertTo(image32f, CV_32F); Mat mu; blur(image32f, mu, Size(3, 3)); Mat mu2; blur(image32f.mul(image32f), mu2, Size(3, 3)); Mat sigma; cv::sqrt(mu2 - mu.mul(mu), sigma); imshow("coke", mat2gray(image32f)); imshow("mu", mat2gray(mu)); imshow("sigma",mat2gray(sigma)); waitKey(); return 0; } </code></pre> <p>This produces the following images:</p> <h2>Original</h2> <p><img src="https://i.stack.imgur.com/V8Zso.jpg" alt="enter image description here"></p> <h2>Mean</h2> <p><img src="https://i.stack.imgur.com/9e53R.jpg" alt="enter image description here"></p> <h2>Standard Deviation</h2> <p><img src="https://i.stack.imgur.com/fAclA.jpg" alt="enter image description here"></p> <p>Hope that helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload