ANP-Granular / ParticleTracking

Library and GUI for tracking (rod-like) particles on camera images in 2D and 3D
https://particletracking.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 2 forks source link

[Feature request] Fast change of rod length #46

Closed dmitrypuzyrev closed 2 years ago

dmitrypuzyrev commented 2 years ago

During the automatic detection step there was a systematic overestimation of rod length (basically in the detection script there is a bord parameter which increases/decreases the rod length after the endpoinds are calculated from the region masks). This parameter was not chosen well for the current rod mixture experiment. Unfortunately it cannot now be automatically fixed, since many endpoints were already manually corrected.

I think the easiest way to fix it is to go through the frames and have a quick way to decrease the selected rod length for x pixels from both sides, x value can be changed in Preferences, the defauld x value can be 2. It should be accessible from a single button keyboard shortcut. It might make sense to have an adjacent button which increases the rod length for x for both sides.

The operation that does the length adjustment by +bord pixels from both sides, for the rod with endpoint coordinates x1,x2,y1,y2, is the following (from "detect_rods_d7_FT2020gp[].ipynb" script):

vX = x2 - x1
vY = y2 - y1

vN = np.linalg.norm([vX,vY])

nvX = vX / vN
nvY = vY / vN

x1 = x1 - bord*nvX
x2 = x2 + bord*nvX

y1 = y1 - bord*nvY
y2 = y2 + bord*nvY

Maybe this does not have to be included in the main branch, since ideally it might be not a common procedure) We can think of it after it's implemented. If you have an alternative or improved solution for this problem, please suggest it.

dmitrypuzyrev commented 2 years ago

The feature is added and the issue closed.