[superpixel_out_cell] = fn_make_superpixel(Istd, N_sup, option);
The function fn_make_superpixel takes as input the list of number of superpixel in each level and outputs a cell array containing field of superpixel indices indicated in the list.
superpixel_out_cell: : A (1 x # of superpixel scales) cell array each of whose level contains superpixel indices running from 1 to the # of superpixel in the level. The cell array can have as many level as needed, and we might not use all of them though. The field names are
Istd: The N_row x N_col (x 3 for RGB and x1 for gray-scale) image matrix.
N_sup: The (row vector) list of the desired number of superpixels
option: The detailed option for superpixel-making algorithm.
field names
"min_pix_allowed"
description
if any superpixel contains fewer pixels than this many, the superpixel is regarded as an 'outlier', and hence will be merged with the 'best-neighbor' superpixel, the neighbor superpixel sharing with the outlier the longest boundary among all of its neighbors.
N_sup = [3 5 10 20 30 50 60 80 100 120 140 150 180 200 220 250]; % number of superpixels for each level
option = {};
option.min_pix_allowed = 3; % every superpixel MUST contain at least this many pixels
[superpixel_out_cell] = fn_make_superpixel(Istd, N_sup, option);
In this example, there are 16 resolutions of interest from 3, 5, 10, ..., and 250. We also emphasize that every superpixel MUST contain at least 3 pixels, otherwise will be merged with its best neighbor.
Note that the actual number of superpixel output by the algorithm is not necessarily the same as the desired one.