Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The centroid-to-centroid distance between an object & itself can be > 0 #1249

Closed
petebankhead opened this issue Mar 2, 2023 · 0 comments
Closed
Labels

Comments

@petebankhead
Copy link
Member

Bug report

Describe the bug
See https://forum.image.sc/t/distances-between-objects-and-annotations/77933

To Reproduce
Steps to reproduce the behavior:

  1. Open an image
  2. Detect and classify cells (e.g. with Positive cell detection)
  3. Run Analyse → Spatial analysis → Detect centroid distances 2D
  4. Check the distance for several objects between themselves and objects with the same class. This is usually 0, but can be greater than 0.

Expected behavior
The distance between an object and itself should always be 0.

The underlying issue seems to be a rounding error due to the way the calculation is performed:

public static void centroidToCentroidDistance2D(Collection<PathObject> sourceObjects, Collection<PathObject> targetObjects, double pixelWidth, double pixelHeight, String measurementName) {

This involved converting objects to points, and the geometries will likely have precision models applied.

Desktop (please complete the following information):

  • OS: Likely all
  • QuPath Version: 0.4.3 (but no known relevant changes made recently, so probably earlier versions too)

Additional context
When fixing this, it may also be possible to make the calculation more efficient by checking for object matches in the source and target list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant