Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thomas Pitiot
CGoGN
Commits
ddefd869
Commit
ddefd869
authored
Feb 22, 2011
by
Kenneth Vanhoey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lf decimation
parent
f61a4b22
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
33 deletions
+56
-33
include/Algo/Decimation/lightfieldApproximator.h
include/Algo/Decimation/lightfieldApproximator.h
+2
-2
include/Algo/Decimation/lightfieldApproximator.hpp
include/Algo/Decimation/lightfieldApproximator.hpp
+10
-6
include/Algo/Decimation/selector.hpp
include/Algo/Decimation/selector.hpp
+2
-1
include/Utils/quadricRGBfunctions.h
include/Utils/quadricRGBfunctions.h
+10
-2
include/Utils/quadricRGBfunctions.hpp
include/Utils/quadricRGBfunctions.hpp
+32
-22
No files found.
include/Algo/Decimation/lightfieldApproximator.h
View file @
ddefd869
...
...
@@ -76,12 +76,12 @@ public:
protected:
AttributeHandler
<
MATRIX33
>
m_frame
;
AttributeHandler
<
MATRIX33
>
m_approxFrame
;
Auto
AttributeHandler
<
QuadricRGBfunctions
<
REAL
>
>
*
m_quadricRGBfunctions
;
AttributeHandler
<
QuadricRGBfunctions
<
REAL
>
>
m_quadricRGBfunctions
;
public:
Approximator_RGBfunctions
(
MAP
&
m
,
AttributeHandler
<
MATRIX36
>&
rgbfunctions
,
Predictor
<
PFP
,
MATRIX36
>*
pred
=
NULL
)
:
Approximator
<
PFP
,
MATRIX36
>
(
m
,
rgbfunctions
,
EDGE_ORBIT
,
pred
)
{}
{
}
~
Approximator_RGBfunctions
()
{}
ApproximatorType
getType
()
const
{
return
A_LightfieldFull
;
}
...
...
include/Algo/Decimation/lightfieldApproximator.hpp
View file @
ddefd869
...
...
@@ -104,14 +104,14 @@ bool Approximator_RGBfunctions<PFP>::init()
// get actual frames and hypothetical approximated frames
m_frame
=
this
->
m_map
.
template
getAttribute
<
MATRIX33
>(
VERTEX_ORBIT
,
"frame"
)
;
m_approxFrame
=
this
->
m_map
.
template
getAttribute
<
MATRIX33
>(
EDGE_ORBIT
,
"approx_frame"
)
;
m_quadricRGBfunctions
=
this
->
m_map
.
template
getAttribute
<
QuadricRGBfunctions
<
REAL
>
>
(
EDGE_ORBIT
,
"quadricRGBfunctions"
)
;
// create quadric embedding for computing and set them to 0
m_quadricRGBfunctions
=
new
AutoAttributeHandler
<
QuadricRGBfunctions
<
REAL
>
>
(
this
->
m_map
,
EDGE_ORBIT
)
;
for
(
Dart
d
=
this
->
m_map
.
begin
()
;
d
!=
this
->
m_map
.
end
()
;
this
->
m_map
.
next
(
d
))
(
*
m_quadricRGBfunctions
)
[
d
].
zero
()
;
m_quadricRGBfunctions
[
d
].
zero
()
;
// Check on embeddings
if
(
!
m_frame
.
isValid
()
||
!
m_approxFrame
.
isValid
()
||
!
m_quadricRGBfunctions
->
isValid
())
if
(
!
m_frame
.
isValid
()
||
!
m_approxFrame
.
isValid
()
||
!
m_quadricRGBfunctions
.
isValid
())
{
std
::
cerr
<<
"Approximator_RGBfunctions::init() --> No approxPosition or no quadricRGBfunctions specified"
<<
std
::
endl
;
return
false
;
...
...
@@ -162,12 +162,16 @@ void Approximator_RGBfunctions<PFP>::approximate(Dart d)
assert
(
-
3.15
<
alpha2
&&
alpha2
<=
3.15
)
;
// Create and sum quadrics
(
*
m_quadricRGBfunctions
)[
d
]
+=
QuadricRGBfunctions
<
REAL
>
(
this
->
m_attrV
[
d
],
gamma1
,
alpha1
)
;
(
*
m_quadricRGBfunctions
)[
d
]
+=
QuadricRGBfunctions
<
REAL
>
(
this
->
m_attrV
[
dd
],
gamma2
,
alpha2
)
;
m_quadricRGBfunctions
[
d
]
+=
QuadricRGBfunctions
<
REAL
>
(
this
->
m_attrV
[
d
],
gamma1
,
alpha1
)
;
m_quadricRGBfunctions
[
d
]
+=
QuadricRGBfunctions
<
REAL
>
(
this
->
m_attrV
[
dd
],
gamma2
,
alpha2
)
;
std
::
cout
<<
"plop"
<<
std
::
endl
;
std
::
cout
<<
m_quadricRGBfunctions
[
d
]
<<
std
::
endl
;
// Compute new function
if
(
!
(
*
m_quadricRGBfunctions
)
[
d
].
findOptimizedRGBfunctions
(
this
->
m_approx
[
d
]))
if
(
!
m_quadricRGBfunctions
[
d
].
findOptimizedRGBfunctions
(
this
->
m_approx
[
d
]))
{
this
->
m_approx
[
d
]
=
this
->
m_attrV
[
d
];
// if fail take first one
}
// std::cout << "Approx of : " <<std::endl ;
// std::cout << "Frame1 : " << m_frame[d] << std::endl ;
...
...
include/Algo/Decimation/selector.hpp
View file @
ddefd869
...
...
@@ -711,10 +711,11 @@ void EdgeSelector_Lightfield<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
MATRIX36
newRGBf
=
this
->
m_RGBfunctionsApproximator
->
getApprox
(
d
)
;
// get newRGBf
QuadricRGBfunctions
<
typename
PFP
::
REAL
>
quadRGBf
=
quadricRGBfunctions
[
d
];
// get quadricRGBf
// ?? test if quadRGBf is valid
// Compute error
REAL
err
=
quad
(
newPos
)
+
(
2
*
acos
(
n1
*
n2
))
+
quadRGBf
(
newRGBf
)
;
// std::cout << err << " -- " << quad(newPos) << " -- " << (2 * acos (n1 * n2)) << " -- " << quadRGBf(newRGBf) << std::endl ;
std
::
cout
<<
quadRGBf
<<
std
::
endl
;
einfo
.
it
=
edges
.
insert
(
std
::
make_pair
(
err
,
d
))
;
einfo
.
valid
=
true
;
}
...
...
include/Utils/quadricRGBfunctions.h
View file @
ddefd869
...
...
@@ -30,7 +30,7 @@ public:
typedef
Geom
::
Matrix
<
3
,
6
,
REAL
>
RGBFUNCTIONS
;
private:
MATRIX66
A
[
COLCHANNELS
]
;
MATRIX66
A
;
VEC6
b
[
COLCHANNELS
];
REAL
c
[
COLCHANNELS
];
...
...
@@ -56,7 +56,15 @@ public:
void
zero
()
;
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
QuadricRGBfunctions
&
)
{
return
out
;};
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
QuadricRGBfunctions
&
q
)
{
out
<<
"quadricRGBf : "
<<
std
::
endl
;
out
<<
"q.A"
<<
"= "
<<
q
.
A
<<
std
::
endl
;
for
(
unsigned
int
i
=
0
;
i
<
3
;
++
i
)
{
out
<<
"q.b["
<<
i
<<
"] = "
<<
q
.
b
[
i
]
<<
std
::
endl
;
out
<<
"q.c["
<<
i
<<
"] = "
<<
q
.
c
[
i
]
<<
std
::
endl
;
}
return
out
;
}
;
friend
std
::
istream
&
operator
>>
(
std
::
istream
&
in
,
const
QuadricRGBfunctions
&
)
{
return
in
;};
private
:
...
...
include/Utils/quadricRGBfunctions.hpp
View file @
ddefd869
...
...
@@ -15,12 +15,12 @@ std::string QuadricRGBfunctions<REAL>::CGoGNnameOfType() {
template
<
typename
REAL
>
QuadricRGBfunctions
<
REAL
>::
QuadricRGBfunctions
()
{
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
]
(
i
,
j
)
=
REAL
(
0
)
;
A
(
i
,
j
)
=
REAL
(
0
)
;
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
b
[
col
][
i
]
=
REAL
(
0
)
;
}
...
...
@@ -35,11 +35,13 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(int i) {
template
<
typename
REAL
>
QuadricRGBfunctions
<
REAL
>::
QuadricRGBfunctions
(
const
QuadricRGBfunctions
&
q
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
(
i
,
j
)
=
q
.
A
(
i
,
j
)
;
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
](
i
,
j
)
=
q
.
A
[
col
](
i
,
j
)
;
b
[
col
][
i
]
=
q
.
b
[
col
][
i
]
;
}
...
...
@@ -58,6 +60,7 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const RGBFUNCTIONS& cf, const REA
buildIntegralMatrix_c
(
R2_c
,
alpha
);
// Parameterized integral matrix c
// Quadric (A,b,c) => L*A*Lt - 2*b*Lt + c = ERROR
A
=
R2_A
;
// Matrix A : integral
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
Geom
::
Vector
<
6
,
REAL
>
function
;
// get function coefficients
if
(
!
cf
.
getSubVectorH
(
col
,
0
,
function
))
...
...
@@ -65,7 +68,6 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const RGBFUNCTIONS& cf, const REA
VEC6
coefs
=
R1
*
function
;
// Rotation 1
A
[
col
]
=
R2_A
;
// Matrix A : integral
b
[
col
]
=
R2_b
*
function
;
// Vector b : integral + rotation on 1 vector
c
[
col
]
=
function
*
(
R2_c
*
function
)
;
// Scalar c : integral + rotation on 2 vectors
}
...
...
@@ -81,7 +83,7 @@ REAL QuadricRGBfunctions<REAL>::operator() (const RGBFUNCTIONS& cf) const {
assert
(
!
"QuadricRGBfunctions::getSubVectorH"
)
;
REAL
res_local
=
REAL
(
0
)
;
res_local
+=
function
*
(
A
[
col
]
*
function
)
;
// l*A*lt
res_local
+=
function
*
(
A
*
function
)
;
// l*A*lt
res_local
-=
2
*
(
function
*
b
[
col
])
;
// -2*l*b
res_local
+=
c
[
col
]
;
// c
// res = l*A*lT - 2*l*b + c
...
...
@@ -93,14 +95,14 @@ REAL QuadricRGBfunctions<REAL>::operator() (const RGBFUNCTIONS& cf) const {
template
<
typename
REAL
>
bool
QuadricRGBfunctions
<
REAL
>::
findOptimizedRGBfunctions
(
RGBFUNCTIONS
&
cf
)
const
{
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
MATRIX66
Ainv
;
REAL
det
=
A
[
col
]
.
invert
(
Ainv
)
;
// Invert matrix
REAL
det
=
A
.
invert
(
Ainv
)
;
// Invert matrix
if
(
det
>
-
1e-8
&&
det
<
1e-8
)
return
false
;
// invert failed
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
VEC6
coefs
=
Ainv
*
b
[
col
];
// function = A^(-1) * b
if
(
!
cf
.
setSubVectorH
(
col
,
0
,
coefs
))
// save in argument cf
...
...
@@ -528,11 +530,13 @@ void QuadricRGBfunctions<REAL>::buildRotateMatrix(MATRIX66 &N, const REAL gamma)
template
<
typename
REAL
>
void
QuadricRGBfunctions
<
REAL
>::
operator
+=
(
const
QuadricRGBfunctions
&
q
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
(
i
,
j
)
+=
q
.
A
(
i
,
j
);
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
](
i
,
j
)
+=
q
.
A
[
col
](
i
,
j
);
b
[
col
][
i
]
+=
q
.
b
[
col
][
i
];
}
c
[
col
]
+=
q
.
c
[
col
];
...
...
@@ -542,11 +546,13 @@ void QuadricRGBfunctions<REAL>::operator += (const QuadricRGBfunctions& q) {
template
<
typename
REAL
>
void
QuadricRGBfunctions
<
REAL
>::
operator
-=
(
const
QuadricRGBfunctions
&
q
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
(
i
,
j
)
-=
q
.
A
(
i
,
j
);
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
b
[
col
][
i
]
-=
q
.
b
[
col
][
i
];
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
](
i
,
j
)
-=
q
.
A
[
col
](
i
,
j
);
}
c
[
col
]
-=
q
.
c
[
col
];
...
...
@@ -555,11 +561,13 @@ void QuadricRGBfunctions<REAL>::operator -= (const QuadricRGBfunctions& q) {
template
<
typename
REAL
>
void
QuadricRGBfunctions
<
REAL
>::
operator
*=
(
const
REAL
v
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
(
i
,
j
)
*=
v
;
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
b
[
col
][
i
]
*=
v
;
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
](
i
,
j
)
*=
v
;
}
c
[
col
]
*=
v
;
...
...
@@ -568,11 +576,13 @@ void QuadricRGBfunctions<REAL>::operator *= (const REAL v) {
template
<
typename
REAL
>
void
QuadricRGBfunctions
<
REAL
>::
operator
/=
(
const
REAL
v
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
(
i
,
j
)
/=
v
;
for
(
unsigned
col
=
RED
;
col
<
BLUE
+
1
;
++
col
)
{
for
(
unsigned
i
=
0
;
i
<
6
;
++
i
)
{
b
[
col
][
i
]
/=
v
;
for
(
unsigned
j
=
0
;
j
<
6
;
++
j
)
A
[
col
](
i
,
j
)
/=
v
;
}
c
[
col
]
/=
v
;
...
...
@@ -581,8 +591,8 @@ void QuadricRGBfunctions<REAL>::operator /= (const REAL v) {
template
<
typename
REAL
>
void
QuadricRGBfunctions
<
REAL
>::
zero
()
{
A
.
zero
();
for
(
unsigned
int
i
=
0
;
i
<
COLCHANNELS
;
++
i
)
{
A
[
i
].
zero
();
b
[
i
].
zero
();
c
[
i
]
=
REAL
(
0
)
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment