soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
437 stars 131 forks source link

Locate only within specific ROI #760

Closed PabloAu closed 1 month ago

PabloAu commented 2 months ago

Hi,

It would be really useful to have an optional Polygon input to the function trackpy.locate, so that the particles are only localized within a certain ROI. Right now, I am localizing all the particles in the image and then filtering them using shapely and geopandas libraries, but this takes a lot of processing time.

If something like already exists or there is a better alternative, please let me know.

Thanks,

Pablo.

nkeim commented 2 months ago

Have you tried masking the image before processing? That is usually a large speed up. You could also experiment with the brightness threshold and the number of iterations for position refinement; those tend to have a large effect on how much effort is spent on spurious particles.

On Apr 15, 2024, at 8:37 AM, Pablo Aurelio Gómez García @.***> wrote:



Hi,

It would be really useful to have an optional Polygon input to the function trackpy.locate, so that the particles are only localized within a certain ROI. Right now, I am localizing all the particles in the image and then filtering them using shapely and geopandas libraries, but this takes a lot of processing time.

If something like already exists or there is a better alternative, please let me know.

Thanks,

Pablo.

— Reply to this email directly, view it on GitHubhttps://github.com/soft-matter/trackpy/issues/760, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAWY23NPPJH3I32DI5FV6MLY5PCZXAVCNFSM6AAAAABGHIVCFKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2DGNJXGUYDEMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

PabloAu commented 2 months ago

Thanks @nkeim.

I am just masking the image before and multiplying the image stack by the mask when imputing into batch locate: tp.batch(frames*mask, ...)

It works.