Skip to content

Commit

Permalink
Only determine segments for single-channel images
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed Jul 17, 2023
1 parent 0b25efb commit 10712d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion panimg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ def add_value_range_meta_data(cls, image: Image): # noqa: B902, N805

@property
def segments(self) -> Optional[FrozenSet[int]]:
if self.image.GetPixelIDValue() not in MASK_TYPE_PIXEL_IDS:
if (
self.image.GetNumberOfComponentsPerPixel() != 1
or self.image.GetPixelIDValue() not in MASK_TYPE_PIXEL_IDS
):
# Only single channel, 8 bit images should be checked.
# Everything else is not a segmentation
return None

im_arr = GetArrayViewFromImage(self.image)
Expand Down

0 comments on commit 10712d1

Please sign in to comment.