0

I try algorithm in paper for triangle have points (0;0), (1;0), (1, 1/2) but get answer I think is wrong (calculation is below): http://faculty.cs.tamu.edu/schaefer/research/wavelet_rasterization.pdf

Basic idea is this algorithm calculate faction area polygon covers inside square region by use Haar wavelets, if polygon cover whole region than value is 1, if half 1/2, etc. Then algorithm subdivide this square region (quadrant) and calculates correction for next level higher resolution. Region size is aways power of two and stop subdivide when region size become 1 x 1 pixel area. Only need subdivide quadrants of this square region if have polygon edge inside that quadrant (I guess quadrant have value less than 1 or greater than 0).

For calculate wavelet coefficients c_xx, algorithm always normalize polygon edges have coordinates 0 ≤ x ≤ 1; 0 ≤ y ≤ . After have wavelet coefficients can use this equation (if I understand this correct): g(p) = (++ c_00)•Ψ_00 + (++ c_10)•Ψ_10 + (++ c_01)•Ψ_01 + (++ c_11)•Ψ_11
for calculate value in each quadrant. I guess g(p) is faction area polygon covers quadrant.
Ψ_00; Ψ_10, Ψ_01,Ψ_11 is Haar wavelet functions in paper's figure 2.

For apply algorithm, first sum (++ c_00) use polygon edges inside whole square region
c_00 += 1/2•det(v_0; v_1)
v_0; v_1 is end points of one polygon edge, normalize coordinates relative with square region (0 ≤ v_0; v_1 ≤ 1).

For calculate other three sum ++ c_10, ++ c_01, ++ c_11, subdivide polygon edges in each quadrant and normalize in each quadrant. Paper's notation for 4 quadrants:
Q_00: left bottom subregion
Q_10: right bottom subregion
Q_01: left top subregion
Q_11: right top subregion

Equations for calculate sums for c_10, c_01, and c11 in appendix A of paper (I not want try type them here).

CALCULATION

For experiment I use this triangle have edges (already normalize)
(0;0) to (1;0)
(1;0) to (1, 1/2)
(1, 1/2) to (0;0)

Triangle and quadrants. Coordinate for edges in quadrant Q00 and Q10 normalized in each quadrant

calculate c_00

Edge (0;0) to (1;0)
c_00 = 1/2•(0•0 - 1•0) = 0
Edge (1;0) to (1, 1/2)
c_00 = 1/2•(1•1/2 - 1•0) = 1/4
Edge
c_00 = 1/2•(1•0 - 0•1/2) = 0

Sum c_00 for all 3 edges:
++ c_00 = 0 + 1/4 + 0 = 1/4 (triangle cover 1/4 area of square region, this number look correct)

calculate c_10, c_01, c_11

Edge (0; 0) to (1; 0) in two qandrants Q_00 and Q_10
Q_00: (0; 0) to (1/2; 0) normalize become --> (0; 0) to (1; 0)
Q_10: (1/2;0) to (1; 0) normalize become --> (0; 0) to (1; 0)
Lx_00 = 1/8•(0 - 0)•(0 + 1) = 0
Ly_00 = 1/8•(1 - 0)•(0 + 0) = 0
Kx_10 = 1/4•(0 - 0) = 0
Lx_10 = 1/8•(0 - 0)(0 + 1) = 0
Ly_10 = 1/8•(1 - 0)
(0 + 0) = 0
c_10 = 0
c_01 = 0
c_11 = 0

Edge (1; 0) to (1; 1/2) only in quadrant Q_10
Q_10: (1:0) to (1; 1/2) normalize become --> (1; 0) to (1; 1)
Kx_10 = 1/4•(0 - 1) = -1/4
Lx_10 = 1/8•(0 - 1)(1 + 1) = -1/4
Ly_10 = 1/8•(0 - 0)(1 + 0) = 0
c_10 = 0 + 0 + -1/4 - (-1/4) + 0 + 0 = 0
c_01 = 0 + 0 + 0 - 0 + 0 - 0 = 0
c_11 = 0 - 0 + -1/4 - (-1/4) - 0 + 0 = 0

Edge (1; 1/2) to (0; 0) in two quadrants Q_00 and Q_10
Q_00: (1/2; 1/4) to (0; 0) normalize become --> (0; 0) to (1; 1/2)
Q_10: (1; 1/2) to (1/2; 1/4) normalize become --> (1; 1) to (0; 1/2)
Lx_00 = 1/8•(1/2 - 0)•(0 + 1) = 1/16
Ly_00 = 1/8•(0 - 1)•(0 + 1/2) = -1/16
Kx_10 = 1/4•(1 - 1/2) = 1/8
Lx_10 = 1/8•(1 - 1/2)(0 + 1) = 1/16
Ly_10 = 1/8•(0 - 1)
(1 + 1/2) = -1/8*(3/2) = -3/16
c_10 = 1/16 + 0 + 1/8 - (1/16) + 0 - 0 = 1/8
c_01 = -1/16 + -3/16 + 0 - 0 + 0 + 0 = -1/4
c_11 = 1/16 - 0 + 1/8 - (1/16) - 0 + 0 = 1/8

++ c_00 = 1/4
++ c_10 = 1/8
++ c_01 = -1/4
++ c_11 = 1/8

Calculate final result:

g00 = c00 + c10 + c01 + c11 = 1/4 + 1/8 + (-1/4) + 1/8 = 1/4
g10 = c00 - c10 + c01 - c11 = 1/4 - 1/8 + (-1/4) - 1/8 = -1/4
g01 = c00 + c10 - c01 - c11 = 1/4 + 1/8 - (-1/4) - 1/8 = 1/2
g11 = c00 - c10 - c01 + c11 = 1/4 - 1/8 - (-1/4) + 1/8) = 1/2

But I guess correct result should calculate is:
g00 = 1/4
g10 = 3/4
g01 = 0
g11 = 0

Châu
  • 103
  • 1
  • 6

1 Answers1

0

Coefficient c00 is correct but sign for coefficient c10, c01, c11 is opposite:
++ c_00 = 1/4 (correct)
++ c_10 = 1/8 --> -1/8
++ c_01 = -1/4 --> 1/4
++ c_11 = 1/8 --> -1/8

Calculate final result

g00 = c00 + c10 + c01 + c11 = 1/4 + (-1/8) + 1/4 + (-1/8) = 1/4
g10 = c00 - c10 + c01 - c11 = 1/4 - (-1/8) + 1/4 - (-1/8) = 3/4
g01 = c00 + c10 - c01 - c11 = 1/4 + (-1/8) - 1/4 - (-1/8) = 0
g11 = c00 - c10 - c01 + c11 = 1/4 - (-1/8) - 1/4 + (-1/8) = 0

For find this problem I use matrix math. Use value for g00, g10, g01, g11 I think is correct and coefficient for Haar wavelet functions Ψ_00; Ψ_10, Ψ_01,Ψ_11 create matrix system:
|1 1 1 1| |c00| = |1/4|
|1 -1 1 -1| |c10| = |3/4|
|1 1 -1 -1| |c01| = | 0 |
|1 -1 -1 1| |c11| = | 0 |

and solve c00, c10, c01, c11. I also try other test triangles and exact same result show sign of c10, c01, c11 is opposite.

Châu
  • 103
  • 1
  • 6