def to_heatmaps(self, only_nonempty=False, not_none_if_no_nonempty=False):
<EOL>from imgaug.augmentables.heatmaps import HeatmapsOnImage<EOL>if not only_nonempty:<EOL><INDENT>return HeatmapsOnImage.from_0to1(self.arr, self.shape, min_value=<NUM_LIT:0.0>, max_value=<NUM_LIT:1.0>)<EOL><DEDENT>else:<EOL><INDENT>nonempty_mask = np.sum(self.arr, axis=(<NUM_LIT:0>, <NUM_LIT:1>)) > <NUM_LIT:0> + <NUM_LIT><EOL>if np.sum(nonempty_mask) == <NUM_LIT:0>:<EOL><INDENT>if not_none_if_no_nonempty:<EOL><INDENT>nonempty_mask[<NUM_LIT:0>] = True<EOL><DEDENT>else:<EOL><INDENT>return None, []<EOL><DEDENT><DEDENT>class_indices = np.arange(self.arr.shape[<NUM_LIT:2>])[nonempty_mask]<EOL>channels = self.arr[..., class_indices]<EOL>return HeatmapsOnImage(channels, self.shape, min_value=<NUM_LIT:0.0>, max_value=<NUM_LIT:1.0>), class_indices<EOL><DEDENT>
Convert segmentation map to heatmaps object.

Each segmentation map class will be represented as a single heatmap channel.

Parameters
----------
only_nonempty : bool, optional
    If True, then only heatmaps for classes that appear in the segmentation map will be
    generated. Additionally, a list of these class ids will be returned.

not_none_if_no_nonempty : bool, optional
    If `only_nonempty` is True and for a segmentation map no channel was non-empty,
    this function usually returns None as the heatmaps object. If however this parameter
    is set to True, a heatmaps object with one channel (representing class 0)
    will be returned as a fallback in these cases.

Returns
-------
imgaug.HeatmapsOnImage or None
    Segmentation map as a heatmaps object.
    If `only_nonempty` was set to True and no class appeared in the segmentation map,
    then this is None.

class_indices : list of int
    Class ids (0 to C-1) of the classes that were actually added to the heatmaps.
    Only returned if `only_nonempty` was set to True.