find out the orientation, length and radius of capped rectangular object

后端 未结 2 950
死守一世寂寞
死守一世寂寞 2021-02-15 16:55

I have a image as shown as fig.1.\"enter I am trying to fit this binary image with a capped rectan

2条回答
  •  无人及你
    2021-02-15 17:34

    First I have to say that I do not have the answer to all of your questions but I can help you with the orientation.

    I suggest using principal component analysis on the binary image. A good tutorial on PCA is given by Jon Shlens. In Figure 2 of his tutorial there is an example what it can be used for. In Section 5 of his paper you can see some sort of instruction how to compute the principal components. With singular value decomposition it is much easier as shown in Section 6.1.

    To use PCA you have to get measurements for which you want to compute the principal components. In your case each white pixel is a measurement which is represented by the pixel location (x, y)'. You will have N two-dimensional vectors that give your measurements. Thus, your measurement 2xN matrix X is represented by the concatenated vectors.

    When you have built this matrix proceed as given in Section 6.1. The singular values are representing the "strength" of the different components. Thus, the largest singular value represents the long axis of your ellipse. The second largest singular value (and it should only be two at all) is represents the other (perpendicular) axis.

    Remember, if the ellipse is a circle your singular values should be equal but with your discrete image representation you will not get a perfect circle.

提交回复
热议问题