Available with Spatial Analyst license.
Summary
Groups together adjacent pixels that have similar spectral characteristics into segments.
Usage
The input can be any Esri-supported raster, with any valid bit depth.
The Band Index parameter is a list of three bands, separated by a space delimiter.
To achieve optimal results, use the Symbology tab in the dataset properties to interactively stretch your Input Raster so the features you want to classify are apparent. Then use these optimal settings in the stretch raster function to enhance your imagery for optimum results.
See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.
Syntax
SegmentMeanShift (in_raster, {spectral_detail}, {spatial_detail}, {min_segment_size}, {band_indexes})
Parameter | Explanation | Data Type |
in_raster | Select the raster dataset you want to segment. This can be a multispectral or grayscale image. | Raster Layer; Mosaic Layer |
spectral_detail (Optional) | Set the level of importance given to the spectral differences of features in your imagery. Valid values range from 1.0 to 20.0. A higher value is appropriate when you have features you want to classify separately but have somewhat similar spectral characteristics. Smaller values create spectrally smoother outputs. For example, with higher spectral detail in a forested scene, you will be able to have greater discrimination between the different tree species. | Double |
spatial_detail (Optional) | Set the level of importance given to the proximity between features in your imagery. Valid values range from 1.0 to 20. A higher value is appropriate for a scene where your features of interest are small and clustered together. Smaller values create spatially smoother outputs. For example, in an urban scene, you could classify an impervious surface using a smaller spatial detail, or you could classify buildings and roads as separate classes using a higher spatial detail. | Long |
min_segment_size (Optional) | Merge segments smaller than this size with their best fitting neighbor segment. Units are in pixels. | Long |
band_indexes (Optional) | Select the bands you want to use to segment your imagery, separated by a space. You want to select bands that offer the most differentiation between the features of interest. | String |
Return Value
Name | Explanation | Data Type |
out_raster_dataset | Specify a name and extension for the output dataset. If your input was a multispectral image, the output will be an 8-bit RGB image. If the input was a grayscale image, the output will be an 8-bit grayscale image. | Raster |
Code sample
SegmentMeanShift example 1 (Python window)
This example creates an output with a minimum segment size of 20, using the near-infrared, red, and green inputs.
import arcpy
from arcpy.sa import *
seg_raster = SegmentMeanShift("c:/test/moncton.tif", "15", "10", "20", "4 3 2")
seg_raster.save("c:/test/moncton_seg.tif")
SegmentMeanShift example 2 (stand-alone script)
This example performs a SegmentMeanShift to create an output with a minimum segment size of 20, using the near-infrared, red, and green inputs.
# Import system modules
import arcpy
from arcpy.sa import *
# Set local variables
inRaster = "c:/test/moncton.tif"
spectral_detail = "14.5"
spatial_detail = "10"
min_segment_size = "20"
band_indexes = "4 3 2"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute
seg_raster = SegmentMeanShift(inRaster, spectral_detail, spatial_detail,
min_segment_size, min_segment_size)
# Save the output
seg_raster.save("c:/output/moncton_seg.tif")
Environments
Licensing information
- ArcGIS Desktop Basic: Requires Spatial Analyst
- ArcGIS Desktop Standard: Requires Spatial Analyst
- ArcGIS Desktop Advanced: Requires Spatial Analyst