Skip to content

Masked pixels appear in segmentation map #149

@ysBach

Description

@ysBach

The docs says

Masking a pixel is equivalent to setting data to zero and noise (if present) to infinity.

A test case to demonstrate this:

import numpy as np
import sep

mask = np.zeros((7, 7)).astype(bool)
mask[3, 3:] = True
data = np.ones((7, 7))
data[2:5, 2:5] += 20
obj, seg = sep.extract(data, thresh=1,
                       mask=mask, 
                       segmentation_map=True)
print(data)
print(mask.astype(int))
print(seg)
print(obj["x"], obj["y"])
# image
[[ 1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1. 21. 21. 21.  1.  1.]
 [ 1.  1. 21. 21. 21.  1.  1.]
 [ 1.  1. 21. 21. 21.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.]
 [ 1.  1.  1.  1.  1.  1.  1.]]
# mask
[[0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 1 1 1 1]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0]]
# Segmap
[[0 0 0 0 0 0 0]
 [0 1 1 1 1 1 0]
 [0 1 1 1 1 1 0]
 [0 1 1 1 1 1 0]
 [0 1 1 1 1 1 0]
 [0 1 1 1 1 1 0]
 [0 0 0 0 0 0 0]]
# Final x, y
[2.8595679] [3.]

The obj is correctly calculated after masking the pixels. (∵ obj["x"] != 3.0)
However, seg includes masked pixels, too.
I think this might be intentional, because the pixels used for extract can be retrived by seg & ~mask, while the additional segmentation information is given to the user. (I am not sure what is SExtractor's default, as I have never used it)
However, if that's the case, I think the documentation needs a bit more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions