0

I have a depth image but I am manipulating it like a (2d) grayscale image to analyze the shape of the figures I have.

I am trying to get the width (distance) of a shape, as given by this image. The width is shown by the red line, which also follows the direction of vector v2.

I have the vectors shown in the image, resulting of a 2-components PCA to gather the direction of the shape (the shape in the picture is cropped, since I just need the width on red, on this part of the shape).

I have no clue, how to rotate the points to origin, or how to project the points to the line and then to calculate the width, somehow by calculating eucledian distance from min to max.

How to get width given by a set of points that are not aligned to axis?

Ademord
  • 31
  • 1
  • 6
  • Have you tried applying a [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)? – lxop Nov 06 '20 at 01:53
  • Tough to tell by your question, but it looks like you more need a Hough ellipse transform. Check out [`skimage.transform.hough_ellipse`](https://scikit-image.org/docs/dev/auto_examples/edges/plot_circular_elliptical_hough_transform.html). That will give you a state space of [`[(accumulator, yc, xc, a, b, orientation)]`](https://scikit-image.org/docs/dev/api/skimage.transform.html#skimage.transform.hough_ellipse) where `a` and `b` are the major and semimajor axes and `accumulator` is roughly the probability an ellipse (fiber?) exists there. – Daniel F Nov 06 '20 at 08:50

1 Answers1

0

I managed it using a rotated bounding box from cv2, as described by this solution.

Ademord
  • 31
  • 1
  • 6