affine-region-detectors.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Affine region detectors
  2. -----------------------
  3. What is being detected?
  4. ~~~~~~~~~~~~~~~~~~~~~~~
  5. Affine region is basically any region of the image
  6. that is stable under affine transformations. It can be
  7. edges under affinity conditions, corners (small patch of an image)
  8. or any other stable features.
  9. --------------
  10. Available detectors
  11. ~~~~~~~~~~~~~~~~~~~
  12. At the moment, the following detectors are implemented
  13. - Harris detector
  14. - Hessian detector
  15. --------------
  16. Algorithm steps
  17. ~~~~~~~~~~~~~~~
  18. Harris and Hessian
  19. ^^^^^^^^^^^^^^^^^^
  20. Both are derived from a concept called Moravec window. Lets have a look
  21. at the image below:
  22. .. figure:: ./Moravec-window-corner.png
  23. :alt: Moravec window corner case
  24. Moravec window corner case
  25. As can be noticed, moving the yellow window in any direction will cause
  26. very big change in intensity. Now, lets have a look at the edge case:
  27. .. figure:: ./Moravec-window-edge.png
  28. :alt: Moravec window edge case
  29. Moravec window edge case
  30. In this case, intensity change will happen only when moving in
  31. particular direction.
  32. This is the key concept in understanding how the two corner detectors
  33. work.
  34. The algorithms have the same structure:
  35. 1. Compute image derivatives
  36. 2. Compute Weighted sum
  37. 3. Compute response
  38. 4. Threshold (optional)
  39. Harris and Hessian differ in what **derivatives they compute**. Harris
  40. computes the following derivatives:
  41. ``HarrisMatrix = [(dx)^2, dxdy], [dxdy, (dy)^2]``
  42. (note that ``d(x^2)`` and ``(dy^2)`` are **numerical** powers, not gradient again).
  43. The three distinct terms of a matrix can be separated into three images,
  44. to simplify implementation. Hessian, on the other hand, computes second
  45. order derivatives:
  46. ``HessianMatrix = [dxdx, dxdy][dxdy, dydy]``
  47. **Weighted sum** is the same for both. Usually Gaussian blur
  48. matrix is used as weights, because corners should have hill like
  49. curvature in gradients, and other weights might be noisy.
  50. Basically overlay weights matrix over a corner, compute sum of
  51. ``s[i,j]=image[x + i, y + j] * weights[i, j]`` for ``i, j``
  52. from zero to weight matrix dimensions, then move the window
  53. and compute again until all of the image is covered.
  54. **Response computation** is a matter of choice. Given the general form
  55. of both matrices above
  56. ``[a, b][c, d]``
  57. One of the response functions is
  58. ``response = det - k * trace^2 = a * c - b * d - k * (a + d)^2``
  59. ``k`` is called discrimination constant. Usual values are ``0.04`` -
  60. ``0.06``.
  61. The other is simply determinant
  62. ``response = det = a * c - b * d``
  63. **Thresholding** is optional, but without it the result will be
  64. extremely noisy. For complex images, like the ones of outdoors, for
  65. Harris it will be in order of 100000000 and for Hessian will be in order
  66. of 10000. For simpler images values in order of 100s and 1000s should be
  67. enough. The numbers assume ``uint8_t`` gray image.
  68. To get deeper explanation please refer to following **paper**:
  69. `Harris, Christopher G., and Mike Stephens. "A combined corner and edge
  70. detector." In Alvey vision conference, vol. 15, no. 50, pp. 10-5244.
  71. 1988. <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.434.4816&rep=rep1&type=pdf>`__
  72. `Mikolajczyk, Krystian, and Cordelia Schmid. "An affine invariant interest point detector." In European conference on computer vision, pp. 128-142. Springer, Berlin, Heidelberg, 2002. <https://hal.inria.fr/inria-00548252/document>`__
  73. `Mikolajczyk, Krystian, Tinne Tuytelaars, Cordelia Schmid, Andrew Zisserman, Jiri Matas, Frederik Schaffalitzky, Timor Kadir, and Luc Van Gool. "A comparison of affine region detectors." International journal of computer vision 65, no. 1-2 (2005): 43-72. <https://hal.inria.fr/inria-00548528/document>`__