improve convexityDefects and externalContours algorithms · Issue #826 · image-js/image-js · GitHub
Skip to content

improve convexityDefects and externalContours algorithms #826

Open

Description

@EscapedGibbon

Currently there are some issues with convexityDefects detection:
A mask like this:

[
    [0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
    [1, 1, 1, 1, 1, 1, 1],
    [0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0],
  ]

will give us these points:

[
  { column: 3, row: 0 },
  { column: 3, row: 1 },
  { column: 3, row: 2 },
  { column: 4, row: 3 },
  { column: 5, row: 3 },
  { column: 6, row: 3 },
  { column: 3, row: 4 },
  { column: 3, row: 5 },
  { column: 3, row: 6 },
  { column: 2, row: 3 },
  { column: 1, row: 3 },
  { column: 0, row: 3 }
]

We get points that are unique but they don't exactly form a homogenous contour. This creates issues with finding convexity defects.
Another potential issue is that currently we use convex hull points that are extended for correct surface calculation. This is not really fitting for calculating defects.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions