PeakSearch

Link to the in-source documentation

Searches for peaks in an image. Peaks are defined as points whose values are higher than the values of all the points in a surrounding area. The list of peaks found by the algorithm can be retrieved by the user using the function GetPeakList. Peaks found in successive applications of the algorithm are appended to the list of previously found peaks unless the user clears the list using the function ClearPeakList. This algorithm supports 1D, 2D, as well as 3D images.

A candidate pixel C will be accepted as a peak under the following conditions:

  1. its value must be larger than thd_value
  2. its value must be outer_limit larger than all values of the outer window pixels
  3. its value must be inner_limit larger than all values of the inner window pixels
  4. there must be at least inner_count_lim pixels in the inner window that have a value larger than inner_count_val

Note that the outer window does not include the inner window region.

When instantiating the algorithm, the user can specify the widths of an inner and an outer window, and sensitivities values for the two windows. These sensitivies, multiplied by the standard deviation of the original image, determine how much the value of a peak must raise above the values of all the points within a window. The user can also define a count threshold and a count sensitivity for the inner window. Each found peak will have in his inner window at least a number of points equal to the count threshold whose values are above the count sensitivity multiplied by the standard deviation.

Using member functions the user can define two radii and restrict the peak search only to points whose distance from the image origin falls between the two radii. Other regions within the map can be excluded from the search by adding their extent to an exclusion list. Finally, the user can select a threshold value that a point must raise above to be an considered a peak.

Full scope is iplt::alg::PeakSearch in C++, resp iplt.alg.PeakSearch in Python.

Examples

C++

#include <iostream>

#include <iplt/image.hh>
#include <iplt/alg/peaksearch.hh>

using namespace iplt;

int main() 
{
  ImageHandle img_real = LoadImage("...");

  // The peak search algorithm has:
  // - An outer windows with a radius of 10 pixels
  // - An inner windows with a radius of 5 pixels
  // - The peak must have a value that surpasses at least by
  //   (2.0 * std_dev) the values of all the points in the inner window
  // - The peak must have a value that surpasses at least by
  //   (1.0 * std_dev) the values of all the points in the outer window
  // - The inner window must contain at least 5 points with a value above
  //   (1.0 * std_dev)
  alg::PeakSearch peak_search(10,2.0,5,1.0,5,1.0);
 
  // All points with values below 14.4 are automatically excluded from the search
  peak_search.SetLevel(14.4);
 
  // The search space is reduced to the points whose distance from the origin of the image
  // lies within 6 and 12 pixels
  peak_search.SetRadii(6,12);
 
  // The algorithm is applied
  img_real.ApplyIP(peak_search);
 
  // The peak list is retrieved
  PeakList peak_list = peak_search.GetPeakList();

  // Dump out all peaks
  for(PeakList::const_iterator it=peak_list.begin();it!=peak_list.end();++it) {
    std::cerr << (*it) << std::endl;
  }
 
  // The peak list is cleared. The algorithm is ready for a new search.
  peak_search.ClearPeakList();

  return 0;
}

Python

from alg import PeakSearch

img_real = LoadImage("...")

# The peak search algorithm has:
# - An outer windows with a radius of 10 pixels
# - An inner windows with a radius of 5 pixels
# - The peak must have a value that surpasses at least by
#   (2.0 * std_dev) the values of all the points in the inner window
# - The peak must have a value that surpasses at least by
#   (1.0 * std_dev) the values of all the points in the outer window
# - The inner window must contain at least 5 points with a value above
#   (1.0 * std_dev)
peak_search = PeakSearch(10,2.0,5,1.0,5,1.0)
 
# All points with values below 14.4 are automatically excluded from the search
peak_search.SetLevel(14.4)
 
# The search space is reduced to the points whose distance from the origin of the image
# lies within 6 and 12 pixels
peak_search.SetRadii(6,12)
 
# The algorithm is applied
img_real.ApplyIP(peak_search)
 
# The peak list is retrieved
peak_list = peak_search.GetPeakList()

# all found peaks are dumped out
for p in peak_list:
  print p
 
# The peak list is cleared. The algorithm is ready for a new search.
peak_search.ClearPeakList()


Back to Algorithm List

Attachments