public abstract class SegmentMeanShiftSearch<T extends boofcv.struct.image.ImageBase>
extends java.lang.Object
Performs the search step in mean-shift image segmentation [1]. The mode of a pixel is the point at which mean-shift converges when initialized at that pixel. Pixels which have the same mode belong to the same segment. The weight kernel G(|x-y|^2/h) has independent normalization factors h for spacial and color components. A precomputed Normal distribution is used for the weight kernel.
Output is provided in the form of an image where each pixel contains the index of a region the pixel belongs to. Three other lists provide color value of the region, number of pixels in the region and the location of the mean-shift peak for that region. This output is unlikely to be final processing step since it will over segment the image. Merging of similar modes and pruning of small regions is a common next step.
An approximation of running mean-shift on each pixel is performed if the 'fast' flag is set to true. The approximation is about 5x faster and works by saving the mean-shift trajectory [2]. All points along the trajectory are given the same mode. When performing mean-shift if a pixel is encountered which has already been assigned a mode the search stops. This approximation tends to produce more regions and reduces clustering quality in high texture regions.
NOTES:
CITATIONS:
| Modifier and Type | Field and Description |
|---|---|
protected float |
convergenceTol |
protected T |
image |
protected float |
maxColorDistanceSq |
protected int |
maxIterations |
protected org.ddogleg.struct.FastQueue<float[]> |
modeColor |
protected org.ddogleg.struct.FastQueue<georegression.struct.point.Point2D_I32> |
modeLocation |
protected org.ddogleg.struct.GrowQueue_I32 |
modeMemberCount |
protected float |
modeX |
protected float |
modeY |
protected boofcv.struct.image.GrayS32 |
pixelToMode |
protected boofcv.struct.image.GrayS32 |
quickMode |
protected int |
radiusX |
protected int |
radiusY |
protected float[] |
spacialTable |
protected float[] |
weightTable |
protected int |
widthX |
protected int |
widthY |
| Constructor and Description |
|---|
SegmentMeanShiftSearch(int maxIterations,
float convergenceTol,
int radiusX,
int radiusY,
float maxColorDistance,
boolean fast)
Configures mean-shift segmentation
|
| Modifier and Type | Method and Description |
|---|---|
static float |
distanceSq(float[] a,
float[] b)
Returns the Euclidean distance squared between the two vectors
|
abstract boofcv.struct.image.ImageType<T> |
getImageType() |
org.ddogleg.struct.FastQueue<float[]> |
getModeColor() |
org.ddogleg.struct.FastQueue<georegression.struct.point.Point2D_I32> |
getModeLocation()
Location of each peak in the image
|
boofcv.struct.image.GrayS32 |
getPixelToRegion()
From peak index to pixel index
|
org.ddogleg.struct.GrowQueue_I32 |
getRegionMemberCount()
Number of pixels which each peak as a member
|
abstract void |
process(T image)
Performs mean-shift clustering on the input image
|
protected float |
weight(float distance)
Returns the weight given the normalized distance.
|
protected int maxIterations
protected float convergenceTol
protected int radiusX
protected int radiusY
protected int widthX
protected int widthY
protected float maxColorDistanceSq
protected boofcv.struct.image.GrayS32 pixelToMode
protected boofcv.struct.image.GrayS32 quickMode
protected org.ddogleg.struct.FastQueue<georegression.struct.point.Point2D_I32> modeLocation
protected org.ddogleg.struct.GrowQueue_I32 modeMemberCount
protected org.ddogleg.struct.FastQueue<float[]> modeColor
protected float[] spacialTable
protected float[] weightTable
protected T extends boofcv.struct.image.ImageBase image
protected float modeX
protected float modeY
public SegmentMeanShiftSearch(int maxIterations,
float convergenceTol,
int radiusX,
int radiusY,
float maxColorDistance,
boolean fast)
maxIterations - Maximum number of mean-shift iterations. Try 30convergenceTol - When the change is less than this amount stop. Try 0.005radiusX - Spacial kernel radius x-axisradiusY - Spacial kernel radius y-axismaxColorDistance - Maximum allowed Euclidean distance squared for the color componentfast - Improve runtime by approximating running mean-shift on each pixel. Try true.public abstract void process(T image)
image - Input imagepublic static float distanceSq(float[] a,
float[] b)
protected float weight(float distance)
distance - Normalized Euclidean distance squared. From 0 to 1.public boofcv.struct.image.GrayS32 getPixelToRegion()
public org.ddogleg.struct.FastQueue<georegression.struct.point.Point2D_I32> getModeLocation()
public org.ddogleg.struct.GrowQueue_I32 getRegionMemberCount()
public org.ddogleg.struct.FastQueue<float[]> getModeColor()
public abstract boofcv.struct.image.ImageType<T> getImageType()