Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use peakiness-test. It's a method to find all the possible peak between two local minima, and measure the peakiness based on a formula. If the peakiness higher than a threshold, the peak is accepted.</p> <p>Source: <a href="http://www.cs.ucf.edu/courses/cap6411/cap5415/spring02/Lecture-9-h.pdf" rel="nofollow">UCF CV CAP5415 lecture 9 slides</a></p> <p>Below is my code:</p> <pre><code>public static List&lt;int&gt; PeakinessTest(int[] histogram, double peakinessThres) { int j=0; List&lt;int&gt; valleys = new List&lt;int&gt; (); //The start of the valley int vA = histogram[j]; int P = vA; //The end of the valley int vB = 0; //The width of the valley, default width is 1 int W = 1; //The sum of the pixels between vA and vB int N = 0; //The measure of the peaks peakiness double peakiness=0.0; int peak=0; bool l = false; try { while (j &lt; 254) { l = false; vA = histogram[j]; P = vA; W = 1; N = vA; int i = j + 1; //To find the peak while (P &lt; histogram[i]) { P = histogram[i]; W++; N += histogram[i]; i++; } //To find the border of the valley other side peak = i - 1; vB = histogram[i]; N += histogram[i]; i++; W++; l = true; while (vB &gt;= histogram[i]) { vB = histogram[i]; W++; N += histogram[i]; i++; } //Calculate peakiness peakiness = (1 - (double)((vA + vB) / (2.0 * P))) * (1 - ((double)N / (double)(W * P))); if (peakiness &gt; peakinessThres &amp; !valleys.Contains(j)) { //peaks.Add(peak); valleys.Add(j); valleys.Add(i - 1); } j = i - 1; } } catch (Exception) { if (l) { vB = histogram[255]; peakiness = (1 - (double)((vA + vB) / (2.0 * P))) * (1 - ((double)N / (double)(W * P))); if (peakiness &gt; peakinessThres) valleys.Add(255); //peaks.Add(255); return valleys; } } //if(!valleys.Contains(255)) // valleys.Add(255); return valleys; } </code></pre>
 

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