IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Local Extrema Extraction 2dSee full documentation
Pixels2dextractLocalExtrema2d (inImg,inFeaturesDistX,inFeaturesDistY)
Pixels2dextractLocalExtrema2d (inImg,inFeaturesDistX,inFeaturesDistY,localExtremaConfig)

Detailed Description

finds the local extrema in an image

Given an input 2d gray level image, and depending on the parameters $LocalExtremaConfig$, set by the user, the algorithm returns:

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.

illustrationExtrema2d.png

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

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# half size neighbourhood definition
halfSizeKnlX = 1
halfSizeKnlY = 1
# local extrema configuration definition
threshold = -30
nbTotPoints = 2000
localExtremaConfig = PyIPSDK.createLocalExtremaConfig(PyIPSDK.eLocalExtremumType.eLET_StrictMax, threshold, nbTotPoints)
# local extrema computation
outPixels2d = fd.extractLocalExtrema2d(inImg, halfSizeKnlX, halfSizeKnlY, localExtremaConfig)
# retrieve coordinates of maximum detected extrema
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

// ------------ Calculation on a mono-slice grey level image ------------ //
// Create the local extrema configuration instance, specifying the local extremum type,
// the threshold and the number of total points. All these parameters are optional
LocalExtremaConfigPtr pLocalExtremaConfig = createLocalExtremaConfig(localExtremumType, threshold, nbTotPoints);
// Load the input image
ImagePtr pInImg = loadTiffImageFile(inImgFilePath);
// Extrcat the local extrema, in a given neighbourhood
Pixels2dPtr pExtremaColl = extractLocalExtrema2d(pInImg, halfKnlSizeX, halfKnlSizeY, pLocalExtremaConfig);
// Retrieve the extrema collection
const std::vector< boost::shared_ptr<Pixel2d> > extremaColl = pExtremaColl->getNodeColl<Pixels2d::Coll>();
const ipUInt64 nbPoints = extremaColl.size();
// ------------ Calculation on a multi-slice grey level image ------------ //
// Extrcat the local extrema, in a given neighbourhood
PlanIndexedPixels2dPtr pExtremaColl_multiSlice = multiSlice_extractLocalExtrema2d(pInImg_multiSlice, halfKnlSizeX, halfKnlSizeY, pLocalExtremaConfig);
// Retrieve the extrema collection for the frame 2, the channel 0 and the slice 1
const std::vector< boost::shared_ptr<Pixel2d> > extremaColl_multiSlice = pExtremaColl_multiSlice->getValue(1, 0, 2).getNodeColl<Pixels2d::Coll>();