fn_make_superpixel

[superpixel_out_cell] = fn_make_superpixel(Istd, N_sup, option);

Description

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.

Output

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

  • sup_idx_field: A field of indices of superpixels having the same row/column dimension as the input image
  • N_sup_actual: The actual number of superpixels after removing the invalid superpixels in the superpixel-making process. Note that the actual number is not necessarily the same as the desired number.
  • N_sup_desired: The desired number of superpixel input to the superpixel-making algorithm.

Input

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.

Example

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.