Class SegmentMeanShift<T extends ImageBase<T>>
- All Implemented Interfaces:
Stoppable
Performs mean-shift segmentation on an image. Primary based upon the description provided in [1], it first uses mean-shift to find the mode of each pixel in the image. The mode is the location mean-shift converges to when initialized at a particular pixel. All the pixels which have the same mode, to within tolerance, are combined into one region. Since mean-shift does not guarantee that pixels which have the same label are connected to each other the labeled image is now segmented to ensure connectivity between labels. If a minimum size is specified for a segment then small regions are pruned and their pixels combined into the adjacent region which has the most similar color.
Mean-shift segmentation can be slow but it has the advantage of there being relatively few tuning parameters. Few tuning parameters make it easier to work with and to some extent more robust.
NOTE: Connectivity rule of 4 tends to produce more tightly compact regions while 8 produces fewer regions but with a more complex surface.
[1] 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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ddogleg.struct.Stoppable
Stoppable.Stopped
-
Constructor Summary
ConstructorDescriptionSegmentMeanShift
(SegmentMeanShiftSearch<T> search, MergeRegionMeanShift merge, @Nullable MergeSmallRegions<T> prune, ConnectRule connectRule) Specifies internal classes used by mean-shift. -
Method Summary
Modifier and TypeMethodDescriptionint
The number of regions which it found in the image.DogArray<float[]>
Average color of each regionNumber of pixels in each regionboolean
void
Performs mean-shift segmentation on the input image.void
-
Constructor Details
-
SegmentMeanShift
public SegmentMeanShift(SegmentMeanShiftSearch<T> search, MergeRegionMeanShift merge, @Nullable @Nullable MergeSmallRegions<T> prune, ConnectRule connectRule) Specifies internal classes used by mean-shift.- Parameters:
search
- mean-shift searchmerge
- Used to merge regionsprune
- Prunes small regions and merges them If null then prune step will be skipped.connectRule
- Specify if a 4 or 8 connect rule should be used when segmenting disconnected regions. Try 4
-
-
Method Details
-
process
Performs mean-shift segmentation on the input image. The total number of regions can be found by callinggetNumberOfRegions()
.- Parameters:
image
- Imageoutput
- Storage for output image. Each pixel is set to the region it belongs to.
-
getNumberOfRegions
public int getNumberOfRegions()The number of regions which it found in the image.- Returns:
- Total regions
-
getRegionColor
Average color of each region -
getRegionSize
Number of pixels in each region -
getImageType
-
requestStop
public void requestStop()- Specified by:
requestStop
in interfaceStoppable
-
isStopRequested
public boolean isStopRequested()- Specified by:
isStopRequested
in interfaceStoppable
-