Much faster center of mass implementation
I've sped up the refine center of mass algorithm to be 5-10 times faster on small (512x512px) images, and 1000 (!) times faster on large (2048x2048px) images. This makes finding center of mass on an image with 17000 no problem at all.
The speedup comes from two parts:
- A much more compact center_of_mass calculator that does not depend on scipy. (takes about 2/3 of the time of the previous)
- Cropping a ROI around the atom before masking it, instead of using center of mass on an image where 99% of the image has value=0.
I have written the code so that it is
nopython=True, but I have not added the jit decorator yet. I'll be investigating whether this is worth using.
There is now a nearly duplicate function to
_make_circular_mask. Mine is a bit faster, but I didn't dare try to attack the old version's other uses, hence there are two for now.
Please test and see what you think. For fun I have attached a 2048px HR STEM HAADF image so that people can test in case they need a quick file.