Skip to content

Commit

Permalink
Fixed the lack of mask for LEL images (#1292)
Browse files Browse the repository at this point in the history
* Fixed the lack of mask for LEL images

* Add a check for the LEL image mask data

---------

Co-authored-by: Adrianna Pińska <adrianna.pinska@gmail.com>
  • Loading branch information
markccchiang and confluence authored Aug 18, 2023
1 parent a6c738e commit 3ec97a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed the case-sensitive of reading BUNIT from a file header ([#1187](https://github.com/CARTAvis/carta-backend/issues/1187)).
* Fixed the crash when reading beam table with 64-bit floats ([#1166](https://github.com/CARTAvis/carta-backend/issues/1166)).
* Fixed region spectral profile from FITS gz image ([#1271](https://github.com/CARTAvis/carta-backend/issues/1271)).
* Fixed the lack of mask for LEL images ([#1291](https://github.com/CARTAvis/carta-backend/issues/1291)).
* Fixed file path to save generated image ([#1252](https://github.com/CARTAvis/carta-backend/issues/1252)).

## [4.0.0-beta.1]
Expand Down
18 changes: 18 additions & 0 deletions src/ImageData/FileLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,24 @@ bool FileLoader::GetSlice(casacore::Array<float>& data, const StokesSlicer& stok
// Use ImageExpr for slice
casacore::Array<float> slice_data;
image->doGetSlice(slice_data, slicer);

if (image->isMasked()) {
// Get mask data
casacore::Array<bool> mask_data;
image->getMaskSlice(mask_data, slicer);

if (mask_data.shape() == slice_data.shape()) {
// Reset the pixel value as NaN if its mask is false
casacore::Array<float>::iterator slice_data_iter = slice_data.begin();
casacore::Array<bool>::iterator mask_data_iter = mask_data.begin();
for (; slice_data_iter != slice_data.end(); ++slice_data_iter, ++mask_data_iter) {
if (!*mask_data_iter) {
*slice_data_iter = NAN;
}
}
}
}

data = slice_data; // copy from reference
return true;
} else if (image_type == "RebinImage") {
Expand Down

0 comments on commit 3ec97a1

Please sign in to comment.