CARTAvis / carta-backend

Source code repository for the backend component of CARTA, a new visualization tool designed for the ALMA, the VLA and the SKA pathfinders.
https://cartavis.github.io/
GNU General Public License v3.0
22 stars 10 forks source link

Move Region conversions for matched images to a new class #1347

Closed pford closed 2 months ago

pford commented 7 months ago

Regions are set using their control points (in pixel coordinates) and reference image coordinate system. When the Region needs to be expressed as a casacore::LCRegion (lattice coordinates, i.e. pixel) for analytics or export, its control points are converted to world coordinates to create a casacore::WCRegion, which can be converted to LCRegion in any image using its coordinate system and shape. This common code is used for matched and reference images, so even for the reference image the coordinates are converted pixel->world->pixel. In this case, it would be faster to create the LCRegion from the pixel coordinates.

I propose creating a RegionConverter class to handle the matched image case, so that the Region code only handles pixel coordinates, simplifying this class. RegionConverter will only be created and used in Region when needed for a matched image.

This issue was found while investigating the line spatial profiles performance (#1339) (where many LCRegions are created along the line), but should also improve the performance of other features using regions in the reference image. I am creating a separate issue because of the size of this change. As part of this development, Region tests will also be created to improve the code coverage metrics.