import matplotlib.pyplot as plt
import numpy as np
from photutils.segmentation import SegmentationImage

data = np.array([[1, 1, 0, 0, 4, 4],
                 [0, 0, 0, 0, 0, 4],
                 [0, 0, 3, 3, 0, 0],
                 [7, 0, 0, 0, 0, 5],
                 [7, 7, 0, 5, 5, 5],
                 [7, 7, 0, 0, 5, 5]])
segm = SegmentationImage(data)

fig, ax = plt.subplots()
im = segm.imshow(ax=ax)
fig.colorbar(im, ax=ax)