code: def segment_mask(self, segnum):
          
          binary_data = np.zeros(self.shape)
          binary_data[self.data == segnum] = BINARY_IM_MAX_VAL
          return BinaryImage(binary_data.astype(np.uint8), frame=self.frame)
docs: Returns a binary image of just the segment corresponding to the given number.
  
          Parameters
          ----------
          segnum : int
              the number of the segment to generate a mask for
  
          Returns
          -------
          :obj:`BinaryImage`
               binary image data