image = | superPixels2dImg (inImg,inSuperPixelsParamValue,inCompactness,inNbIter) |
image = | superPixels2dImg (inImg,inSuperPixelsParamValue,inCompactness,inNbIter,inOptSizeRatio,inOptSuperPixelsType) |
function for computing super pixels
The super pixels algorithm is based on the SILC method (Simple Linear Iterative Clustering)
- See also
- https://darshita1405.medium.com/superpixels-and-slic-6b2d8a6e4f08
This algorithm is used to separate an image into super pixels (group of pixels). Those super pixels are computed to follow the contours of the input image. Each pixel is compared with the center of the closest super pixels, and associated to the most similar one, in term of distance and color.
The following parameters allow to optimise the computation of the super pixels:
is the desired number of super pixels, or the desired size of the super pixels, depending on the value of
.
is the ratio between the euclidian distance and the color distance, used to classify a pixel in his corresponding super pixels. With a small value, the super pixels will fit the contours better, and with a high value, the super pixels will be more regular. Advised values are around 0.5.
is the number of iterations used in the algorithm. At the end of each iteration, the center of each super pixel is updated for the next iteration.
is the minimal size of a super pixel (as a fraction of their supposed size). If a super pixel is smaller, it will be removed and replaced by the neighboring super pixels. Default value is 0.5.
define if the first parameter
is the desired number of super pixels, or the desired size of the super pixels. Default value is "Number".
Here is an example (number of super pixels : 500, compactness : 0.5, number of iterations : 3, size ratio : 0.5)
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLAdvancedMorphology as advmorpho
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
superPixelsNumber = 500
compactness = 0.5
nbIter = 3
sizeRatio = 0.5
superPixelsType = PyIPSDK.eSPT_Number
outImg = advmorpho.superPixels2dImg(inImg, superPixelsNumber, compactness, nbIter, sizeRatio,superPixelsType)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLAdvancedMorphology/Processor/SuperPixels2dImg/SuperPixels2dImg.h>
Code Example
ImagePtr pOutBinLabImg = superPixels2dImg(pInImg, 500,0.5,3);