Public methods
Method new()
Usage
Image_Segmentation$new()
Method spixel_segmentation()
Usage
Image_Segmentation$spixel_segmentation(
input_image,
method = "slic",
superpixel = 200,
kmeans_method = "",
AP_data = FALSE,
use_median = TRUE,
minib_kmeans_batch = 10,
minib_kmeans_init_fraction = 0.5,
kmeans_num_init = 3,
kmeans_max_iters = 100,
kmeans_initializer = "kmeans++",
colour_type = "RGB",
compactness_factor = 20,
adjust_centroids_and_return_masks = FALSE,
return_labels_2_dimensionsional = FALSE,
sim_normalize = FALSE,
sim_wL = 3,
sim_wA = 10,
sim_wB = 10,
sim_color_radius = 20,
ap_maxits = 1000,
ap_convits = 100,
ap_dampfact = 0.9,
ap_nonoise = 0,
verbose = FALSE
)
Arguments
input_imagea 3-dimensional input image (the range of the pixel values should be preferably in the range 0 to 255)
methoda character string specifying the superpixel method. It can be either "slic" or "slico"
superpixela numeric value specifying the number of superpixels
kmeans_methoda character string specifying the kmeans method. If not empty ("") then it can be either "kmeans" or "mini_batch_kmeans"
AP_dataa boolean. If TRUE then the affinity propagation image data will be computed and returned
use_mediana boolean. If TRUE then the median will be used rather than the mean value for the inner computations (see the details section for more information)
minib_kmeans_batchthe size of the mini batches
minib_kmeans_init_fractionpercentage of data to use for the initialization centroids (applies if initializer is kmeans++ or optimal_init). Should be a float number between 0.0 and 1.0.
kmeans_num_initnumber of times the algorithm will be run with different centroid seeds
kmeans_max_itersthe maximum number of clustering iterations
kmeans_initializerthe method of initialization. One of, optimal_init, quantile_init, kmeans++ and random. See details for more information
colour_typea character string specifying the colour type. It can be one of "RGB", "LAB" or "HSV"
compactness_factora numeric value specifying the compactness parameter in case that method is "slic"
adjust_centroids_and_return_masksa boolean. If TRUE and the kmeans_method parameter is NOT empty ("") then the centroids will be adjusted and image-masks will be returned. This will allow me to plot the masks using the spixel_masks_show method.
return_labels_2_dimensionsionala boolean. If TRUE then a matrix of labels based on the output superpixels in combination with the Affinity Propagation clusters will be returned
sim_normalizea boolean. If TRUE then the constructed similarity matrix will be normalised to have unit p-norm (see the armadillo documentation for more details)
sim_wLa numeric value specifying the weight for the "L" channel of the image (see the details section for more information)
sim_wAa numeric value specifying the weight for the "A" channel of the image (see the details section for more information)
sim_wBa numeric value specifying the weight for the "B" channel of the image (see the details section for more information)
sim_color_radiusa numeric value specifying the colorradius (see the details section for more information)
ap_maxitsa numeric value specifying the maximum number of iterations for the Affinity Propagation Clustering (defaults to 1000)
ap_convitsa numeric value. If the estimated exemplars stay fixed for convits iterations, the affinity propagation algorithm terminates early (defaults to 100)
ap_dampfacta float number specifying the update equation damping level in [0.5, 1). Higher values correspond to heavy damping, which may be needed if oscillations occur in the Affinity Propagation Clustering (defaults to 0.9)
ap_nonoisea float number. The affinity propagation algorithm adds a small amount of noise to data to prevent degenerate cases; this disables that.
verbosea boolean. If TRUE then information will be printed in the console (spixel_masks_show method)
Method spixel_masks_show()
Usage
Image_Segmentation$spixel_masks_show(
delay_display_seconds = 3,
display_all = FALSE,
margin_btw_plots = 0.15,
verbose = FALSE
)
Arguments
delay_display_secondsa numeric value specifying the seconds to delay the display of the next image (It displays the images consecutively). This parameter applies only if the display_all is set to FALSE (spixel_masks_show method)
display_alla boolean. If TRUE then all images will be displayed in a grid (spixel_masks_show method)
margin_btw_plotsa float number specifying the margins between the plots if the display_all parameter is set to TRUE (spixel_masks_show method)
verbosea boolean. If TRUE then information will be printed in the console (spixel_masks_show method)
Method spixel_clusters_show()
Usage
Image_Segmentation$spixel_clusters_show(
spix_labels,
color_palette = grDevices::rainbow,
parameter_list_png = NULL
)
Arguments
spix_labelsa matrix. I can retrieve the "spix_labels" parameter by setting the "return_labels_2_dimensionsional" parameter to TRUE in the "spixel_segmentation" method (spixel_clusters_show method)
color_paletteone of the color palettes. Use ?grDevices::topo.colors to see the available color palettes
parameter_list_pngeither NULL or a list of parameters passed to the ?grDevices::png function, such as list(filename = 'img.png', width = 100, height = 100, units = "px", pointsize = 12, bg = "white", type = "quartz")
Method clone()
The objects of this class are cloneable with this method.
Usage
Image_Segmentation$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.