Recover the boolean mask associated to a region #544
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is not associated to an issue. The pull request is not ready to be merged yet. Neither tests, nor documentations pages have been created for this pull request yet.
This request implements a 'to_boolean_array' method in both PixelRegion and Regions classes that allows to transform one or multiple (pixel) regions into a boolean mask given an output array shape. A typical use-case would be to load a ds9 region as a boolean mask and be able to directly apply it to some data with a one-liner.
While it is currently possible to do so using either the bounding box attached to the region or, as implemented here, the to_mask and then to_image methods, this process is currently far from trivial. This pull request proposes to add a method that allows to do so with a single method call. The output boolean array will contain True values for pixels within the region(s) and False for pixels outside.
I implemented the 'to_boolean_array' method in PixelRegion because it seemed the easiest to do but it could probably also be implemented in SkyRegion by using the to_pixel method ?
Also, the 'to_boolean_array' method in the Regions class currently does not check whether the region is a Pixel or Sky one.