Construct images without sanity checks in `_convertMask` function in the HSM module
When measuring the moments using FindAdaptiveMom, I find that a significant chunk of time is taken by the _convertMask function, which arises from various Image instantiations. Given that this is an internal function, I expect that the inputs provided to create an Image instance would always pass these checks and can directly use the _Image.
For reference, 38 out of 186 seconds is spend in _convertMask when calling FindAdaptiveMom.
I think the main thing is probably that there are a couple of checks currently that the mask is sane (no negative values and not all zero). So probably adding an option to skip those will speed this up a lot.
Probably simplest would be to add a leading underscore version of this _FindAdaptiveMom that skips all the sanity checks and requires that object_image and weight are already the right dtype and everything.
That sounds like the least disruptive approach to me (not saying that modifying _convertMask would have been), but I could see a user potentially calling FindAdaptiveMom with inconsistent inputs. I'm happy to code this up, quantify the performance improvements and raise a PR here.
An additional public interface to observed_e1 and observed_e2 would also be nice. And the current return for observed_shape should probably use the optimized _Shape rather than Shape.
Closing this issue as completed.