function seg_sel = select_segments(seg_id, seg_sz, seg_gt, params)
% We may want to 
% - ignore the background segments.
% - sample only a few background segments.
% - use all segments.

% Default is to use all segments.
seg_sel = ones(size(seg_id));
if ~isempty(seg_gt)    
    if isfield(params, 'remove_unlabeled') && params.remove_unlabeled
        seg_sel = find(any(seg_gt > 0, 2));
    end
    
    % Sample some background segements 
    % along the boundary of foreground segments.
    % select_seg = all(seg_labels ~= 0, 2);
    % num_fg = sum(select_seg);
    % if params.use_bg_boundary
    %     filled = imfill(any(gt_map ~= 0, 3), 'holes');
    %     boundary = imdilate(filled, strel('line', 11, 90));
    %     boundary = imdilate(boundary, strel('line', 11, 0));
    %     boundary = double(boundary - filled);
    %     % find corresponding segments
    % end
    % bg_segs(logical(bg_segs)) = randperm(sum(bg_segs));
    % bg_segs = (bg_segs > 0) & (bg_segs <= num_fg);
    % select_seg = select_seg | bg_segs;
end
