Improving Efficiency and Speed of dot finding code. (with upwards or 0.3 million dots segmented in a single stack, some substantial changes are necessary).
Profiler on optimizing_dotfinding
caught bug: needed to increase maxdots. Now set automatically.
Slow steps in CheckDotUpDown:
- Converting logical into uint16 inside loop before addition, 59.78s -> 0.58s.
- Removing negative values from matrix: just make the matrix a uint16 instead of a double, negative values go to 0 for free. 40+ s -> 0.2 s.
- Major memory issues: convert everything to uint8, uint16, or single as possible.
- Clear variables as used. Does this help? — Does not appear to.
- One Issue found: regionprops for a large number of objects kills memory and time. watershed, bwareaopen, both use regionprops.
New approach:
These images have are intercollated with blank rows, allowing easy data splitting.
Slowest step is now the find command to match the appropriate z-coordinate. This could be sped up by narrowing the search to the appropriate region. Or just use advanced filtering to ensure correct segmentation and ignore the precise z-determination.