Guest User

Untitled

a guest
Jun 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. """
  2. how do we update the occlusion data?
  3. where does the weight field come from,
  4.  
  5. how is the estimate worked into the main estimation--there's overlap in terms
  6.  
  7. do we work from back to front
  8.  
  9. where the fuck does lambda_o in equation 6 come from?
  10. """
  11.  
  12. SIGMA_E = 0.01 # allowance of acceleration
  13. SIGMA_V = 0.01 # allowance of acceleration
  14. LAMBDA = 2.0
  15. ALPHA = 0.0331 # ~ 3 * SIGMA_V according to section 3.4
  16.  
  17.  
  18. #
  19. # Helpers
  20. #
  21.  
  22. def neighborhood(x_r):
  23. """The function S_n. Returns the eight points surrounding x_r."""
  24. x, y = x_r
  25. return [(x - 1, y - 1), (x, y - 1), (x + 1, y - 1),
  26. (x - 1, y), (x + 1, y),
  27. (x - 1, y + 1), (x, y + 1), (x + 1, y + 1)]
  28.  
  29. def lambda_(s, x_r):
  30. """Discourages 'smoothness' over too large a range."""
  31. return LAMBDA / magnitude(s - x_r)
  32.  
  33. #
  34. # Probability model components
  35. #
  36.  
  37. def p_l(x_r, w_n, w_n_1, d_h, I_n, I_n_1):
  38. """
  39. x_r: x_r
  40. a rig site
  41. w_n: w_n
  42. continuous matrix. 1 indicates data available, 0 indicates data missing.
  43. in the rig area w(x_r) = 0, i.e. this is the "not-rig" matrix
  44. w_n_1: w_n-1
  45. continuous matrix. 1 indicates data available, 0 indicates data missing.
  46. in the rig area w(x_r) = 0, i.e. this is the "not-rig" matrix
  47. d_h: d^h_n,n-1
  48. vector matrix estimating the motion of the hidden area
  49. I_n: I_n
  50. frame at n
  51. I_n_1: I_n-1
  52. frame at n-1
  53. """
  54. # the motion compensated site x_r + d^h_n,n-1(x_r)
  55. x_r_prime = x_r + d_h(x_r)
  56.  
  57. temp = (1. / (2. * (SIGMA_E ** 2.))) *
  58. w_n(x_r) *
  59. w_n_1(x_r_prime) *
  60. ((I_n(x_r) - I_n_1(x_r_prime)) ** 2)
  61.  
  62. return exp(-temp)
  63.  
  64.  
  65. def p_t(x_r, occlusion, data_available, d_estimate, d_prev):
  66. """
  67. x_r:
  68. a rig site
  69. occlusion: o_n,n-1
  70. binary matrix. 1 indicates data that that point in the frame n does not
  71. exist in the frame n-1. 0 indicates no discontinuity
  72. data_available: w_n-1
  73. continuous matrix. 1 indicates data available, 0 indicates data missing.
  74. in the rig area w(x_r) = 0, i.e. this is the "not-rig" matrix
  75. d_estimate: d^h_n,n-1
  76. vector matrix estimating the motion of the hidden area
  77. d_prev: d_n-1,n-2
  78. vector matrix with the motion mapping from frame n-1 to frame n-2
  79. """
  80. # the motion compensated site x_r + d^h_n,n-1(x_r)
  81. x_r_prime = x_r + d_estimate(x_r)
  82.  
  83. temp = (1. / (SIGMA_V ** 2.)) *
  84. (1. - occlusion(x_r)) *
  85. data_available(x_r_prime) *
  86. (magnitude(d_estimate(x_r) - d_prev(x_r_prime)) ** 2.)
  87.  
  88. return exp(-temp)
  89.  
  90.  
  91. def p_s(x_r, d_estimate, d):
  92. """
  93. x_r: rig site
  94. d_estimate: vector matrix estimating motion
  95. of the hidden area, as in other functions
  96. d: matrix of motion vectors (maybe - section 4.1)
  97.  
  98. """
  99. temp = sum(lambda_(s, x_r) * (magnitude(d_estimate(x_r) - d(s)) ** 2.)
  100. for s in neighborhood(x_r))
  101.  
  102. return exp(-temp)
  103.  
  104.  
  105. def p_so(x_r, occlusion):
  106. """
  107. x_r:
  108. a rig site
  109. occlusion: o_n,n-1
  110. binary matrix. 1 indicates data that that point in the frame n does not
  111. exist in the frame n-1. 0 indicates no discontinuity
  112. """
  113. occ = sum(lambda_(s, x_r) * magnitude(occlusion(x_r) - occlusion(s))
  114. for s in neighborhood(x_r))
  115.  
  116. # TODO: is this sum term *actually* the sum of all the occlusion values?
  117. penalty = ALPHA * sum(occlusion)
  118.  
  119. return exp(-acc) * exp(-penalty)
Add Comment
Please, Sign In to add comment