Class SegmentMeanShiftSearch<T extends ImageBase>
- java.lang.Object
-
- boofcv.alg.segmentation.ms.SegmentMeanShiftSearch<T>
-
- Direct Known Subclasses:
- SegmentMeanShiftSearchColor, SegmentMeanShiftSearchGray
public abstract class SegmentMeanShiftSearch<T extends ImageBase> extends java.lang.ObjectPerforms 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:
- Spacial distance is normalized by dividing the found Euclidean distance squared by the maximum possible Euclidean distance squared, thus ensuring it will be between 0 and 1.
- Color distance is normalized by dividing it by the maximum allows Euclidean distance squared. If its distance is more than the maximum allowed value then G() will be zero.
- Image edges are handled by truncating the spacial kernel. This truncation will create an asymmetric kernel, but there is really no good way to handle image edges.
CITATIONS:
- Comaniciu, Dorin, and Peter Meer. "Mean shift analysis and applications." Computer Vision, 1999. The Proceedings of the Seventh IEEE International Conference on. Vol. 2. IEEE, 1999.
- Christoudias, Christopher M., Bogdan Georgescu, and Peter Meer. "Synergism in low level vision." Pattern Recognition, 2002. Proceedings. 16th International Conference on. Vol. 4. IEEE, 2002.
-
-
Constructor Summary
Constructors Constructor and Description SegmentMeanShiftSearch(int maxIterations, float convergenceTol, int radiusX, int radiusY, float maxColorDistance, boolean fast)Configures mean-shift segmentation
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description static floatdistanceSq(float[] a, float[] b)Returns the Euclidean distance squared between the two vectorsabstract ImageType<T>getImageType()FastQueue<float[]>getModeColor()FastQueue<Point2D_I32>getModeLocation()Location of each peak in the imageGrayS32getPixelToRegion()From peak index to pixel indexGrowQueue_I32getRegionMemberCount()Number of pixels which each peak as a memberabstract voidprocess(T image)Performs mean-shift clustering on the input image
-
-
-
Constructor Detail
-
SegmentMeanShiftSearch
public SegmentMeanShiftSearch(int maxIterations, float convergenceTol, int radiusX, int radiusY, float maxColorDistance, boolean fast)Configures mean-shift segmentation- Parameters:
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.
-
-
Method Detail
-
process
public abstract void process(T image)
Performs mean-shift clustering on the input image- Parameters:
image- Input image
-
distanceSq
public static float distanceSq(float[] a, float[] b)Returns the Euclidean distance squared between the two vectors
-
getPixelToRegion
public GrayS32 getPixelToRegion()
From peak index to pixel index
-
getModeLocation
public FastQueue<Point2D_I32> getModeLocation()
Location of each peak in the image
-
getRegionMemberCount
public GrowQueue_I32 getRegionMemberCount()
Number of pixels which each peak as a member
-
getModeColor
public FastQueue<float[]> getModeColor()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG