finds the local extrema in an image
Given an input 2d gray level image, and depending on the parameters
, set by the user, the algorithm returns:
- if
value equals to
, the collection of local maxima of the input image that are greater than the
attribute value. A local maximum is a pixel whose value is greater or equal than the values of all its neighbours defined by the half kernel sizes along the x and y directions
and
. In the case of plateaus, only the first pixel found is selected except for a special case illustrated in the figure below.
- if
value equals to
, the collection of strict local maxima of the input image that are greater than the
attribute value. A strict local maximum is a pixel whose value is strictly greater than the values of all its neighbours defined by the half kernel sizes along the x and y directions
and
.
- if
value equals to
, the collection of local minima of the input image that are lower than the
attribute value. A local minimum is a pixel whose value is lower or equal than the values of all its neighbours defined by the half kernel sizes along the x and y directions
and
. In the case of plateaus, only the first pixel found is selected except for a special case illustrated in the figure below.
- if
value equals to
, the collection of strict local minima of the input image that are lower than the
attribute value. A strict local minimum is a pixel whose value is strictly lower than the values of all its neighbours defined by the half kernel sizes along the x and y directions
and
.
For non strict local extrema calculation, an extremum can belong to a plateau. In this case, the algorithm generally selects the first pixel of the first line of the plateau. However, several local extrema can be found in the same plateau. The following figure illustrates an example of plateau where more than one local extremum is found. The plateau is represented by black pixels and the extrema selected are colored in red in the right figure.
Two wrappers can be called : the extractLocalExtrema2d wrapper is only used to compute the extrema extraction on a grey level 2d images, whereas the multiSlice_extractLocalExtrema2d wrapper must be used for more complex data (volume, sequence and/or color).
The user may handle this behaviour correctly to analyze the obtained results.
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLFeatureDetection as fd
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
halfSizeKnlX = 1
halfSizeKnlY = 1
threshold = -30
nbTotPoints = 2000
localExtremaConfig = PyIPSDK.createLocalExtremaConfig(PyIPSDK.eLocalExtremumType.eLET_StrictMax, threshold, nbTotPoints)
outPixels2d = fd.extractLocalExtrema2d(inImg, halfSizeKnlX, halfSizeKnlY, localExtremaConfig)
maxPixel2d = PyIPSDK.toPyDict(outPixels2d)['Coll'][0]
print("Maximum extrema value " + str(maxPixel2d['Intensity'] ) + " found on coordinates x=" + str(maxPixel2d['X'] ) + " and y=" + str(maxPixel2d['Y'] ))
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLFeatureDetection/Processor/ExtractLocalExtrema2d/ExtractLocalExtrema2d.h>
Code Example
Pixels2dPtr pExtremaColl = extractLocalExtrema2d(pInImg, halfKnlSizeX, halfKnlSizeY, pLocalExtremaConfig);
const std::vector< boost::shared_ptr<Pixel2d> > extremaColl = pExtremaColl->getNodeColl<Pixels2d::Coll>();
const ipUInt64 nbPoints = extremaColl.size();
PlanIndexedPixels2dPtr pExtremaColl_multiSlice = multiSlice_extractLocalExtrema2d(pInImg_multiSlice, halfKnlSizeX, halfKnlSizeY, pLocalExtremaConfig);
const std::vector< boost::shared_ptr<Pixel2d> > extremaColl_multiSlice = pExtremaColl_multiSlice->getValue(1, 0, 2).getNodeColl<Pixels2d::Coll>();