im.classify {imageRy} | R Documentation |
Classify a Raster Image Using K-Means Clustering
Description
This function performs unsupervised classification on a raster image using k-means clustering. It rescales the pixel values to 0–255 to improve visual clustering of scientific TIFFs.
Usage
im.classify(
input_image,
num_clusters = 3,
seed = NULL,
do_plot = TRUE,
custom_colors = NULL,
num_colors = 100
)
Arguments
input_image |
A 'SpatRaster' object representing the input raster image. |
num_clusters |
An integer specifying the number of clusters (default: 3). |
seed |
An optional integer seed for reproducibility of k-means clustering results (default: NULL). |
do_plot |
A logical value indicating whether to display the classified raster (default: TRUE). |
custom_colors |
A vector of custom colors to be used for classification visualization (default: NULL). If NULL, a predefined set of colors is used. |
num_colors |
The number of colors to interpolate in the visualization palette (default: 100). |
Value
A 'SpatRaster' object with cluster assignments.
[Package imageRy version 0.3.0 Index]