1
$\begingroup$

I have an image of an object. The image shows a high contrast outline of the object. It is guaranteed that the image shows exactly one object.

The shape/contour of that outline is known. It is not simple (e.g. a circle) but not too complex either. It is made up of (circular) arcs and straight lines. Think of the outline of the head of mickey mouse in terms of complexity.

Given the image and the knowledge about the shape, how do I determine the position, rotation and scale of the shape and thus the object in the image?


I did some research and Hough transforms seem to be the way to go, but only for lines.

The wikipedia article states that

Altering the algorithm to detect circular shapes instead of lines is relatively straightforward.

I have the impression that as long as I can describe the shape mathematically, I can adopt the algorithm to that shape, because the mathematical model is what defines the transformation. Is that impression (while very rough) correct?

The article states further

For more complicated shapes in the plane (i.e., shapes that cannot be represented analytically in some 2D space), the Generalised Hough transform [12] is used, which allows a feature to vote for a particular position, orientation and/or scaling of the shape using a predefined look-up table.

Is my Mickey Mouse-shape a complicated shape? Do I need the Generalised Hough transform?

Am I on the right track with this hough transform?


I found an implementation in openCV, which lacks scale detection:

finds arbitrary template in the grayscale image using Generalized Hough Transform

Detects position, translation and rotation


Basically speaking, I have an image and some shape description (think of a vector graphic of the outline) and I want to know where it is in the image. Does something like that exists?

I cannot share the image.

$\endgroup$
0

2 Answers 2

0
$\begingroup$

Here's something that should work:

1) Find the center of mass of all your points.

2) Sweep a radius around this center.

3) Measure a few metrics along each radius, generating a set of "periodic signals"

4) Take the DFT of the signals to determine magnification and rotation (as phase shifts).

Off the top of my head and similar to this:

Auto Detection of Rotation Angle on Arbitrary Image with Orthogonal Features


Actually, you shouldn't need to take the whole DFT, just the DC bin and bin 1, perhaps bin 2 for some redundancy.

Some metrics might be:

  1. Point count along radius

  2. Point weighted average along the radius.

2A) weighted by distance to the center

2B) weighted by distance squared

  1. Minimum distance to a point along the radius

  2. Maximum distance for a point along the radius

  3. The average of #3 and #4

$\endgroup$
4
  • $\begingroup$ This is not exactly what I'm going to do, but coming up with a custom solution instead of finding an existing do-it-all algorithm seems to be the way to go. $\endgroup$ Jan 10, 2020 at 8:47
  • $\begingroup$ @user11398730 Agreed. A fixed size wrench is less of a knuckle buster than an adjustable one. Can you give a hint at what you are going to do? $\endgroup$ Jan 10, 2020 at 15:18
  • $\begingroup$ Eventually the goal is to measure shape deviation. This recognition step merely serves as the starting point to find the transformation of the coordinate system of the shape in the image. With that reference established, more specific measurements are taken. $\endgroup$ Jan 13, 2020 at 7:40
  • $\begingroup$ @user11398730 You may have done all the measuring you need. It is much simpler to align the metric functions by shifting than it is to rotate your graphic. After shifting, you have a location and rotation independent measure of your figure in polar form. Any distortions should be readily recognizable in direct comparisons. $\endgroup$ Jan 14, 2020 at 0:53
0
$\begingroup$

A Hough transform can certainly work. However, with position, scale, and orientation, you would have to use a 5-D Hough transform (2 DOF for position, 1 for scale, 1 for orientation), which might be computationally quite demanding.

As an alternative, you might want to look at SIFT or one of its extensions like SURF. It sounds like they can be adapted to do the job. And OpenCV has them.

$\endgroup$
1
  • $\begingroup$ "computationally quite demanding" - I suspected that, thank you for the confirmation $\endgroup$ Jan 10, 2020 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.