Segment¶

class
photutils.segmentation.
Segment
(segment_data, label, slices, bbox, area)[source]¶ Bases:
object
Class for a single labeled region (segment) within a segmentation image.
 Parameters
 segment_dataint
ndarray
A segmentation array where source regions are labeled by different positive integer values. A value of zero is reserved for the background.
 labelint
The segment label number.
 slicestuple of two slices
A tuple of two slices representing the minimal box that contains the labeled region.
 bbox
BoundingBox
The minimal bounding box that contains the labeled region.
 areafloat
The area of the segment in pixels**2.
 segment_dataint
Attributes Summary
A cutout array of the segment using the minimal bounding box, where pixels outside of the labeled region are set to zero (i.e., neighboring segments within the rectangular cutout array are not shown).
A
MaskedArray
cutout array of the segment using the minimal bounding box.Methods Summary
make_cutout
(data[, masked_array])Create a (masked) cutout array from the input
data
using the minimal bounding box of the segment (labeled region).Attributes Documentation

data
¶ A cutout array of the segment using the minimal bounding box, where pixels outside of the labeled region are set to zero (i.e., neighboring segments within the rectangular cutout array are not shown).

data_ma
¶ A
MaskedArray
cutout array of the segment using the minimal bounding box.The mask is
True
for pixels outside of the source segment (i.e., neighboring segments within the rectangular cutout array are masked).
Methods Documentation

make_cutout
(data, masked_array=False)[source]¶ Create a (masked) cutout array from the input
data
using the minimal bounding box of the segment (labeled region).If
masked_array
isFalse
(default), then the returned cutout array is simply andarray
. The returned cutout is a view (not a copy) of the inputdata
. No pixels are altered (e.g., set to zero) within the bounding box.If
masked_array` is `True`, then the returned cutout array is a `~numpy.ma.MaskedArray`, where the mask is `True` for pixels outside of the segment (labeled region). The data part of the masked array is a view (not a copy) of the input ``data
. Parameters
 dataarraylike
The data array from which to create the masked cutout array.
data
must have the same shape as the segmentation array. masked_arraybool, optional
If
True
then aMaskedArray
will be created where the mask isTrue
for pixels outside of the segment (labeled region). IfFalse
, then andarray
will be generated.
 Returns
 result
ndarray
orMaskedArray
The cutout array.
 result