3 #ifndef RENDERER_DETAIL_NORMAL_MRF_H
4 #define RENDERER_DETAIL_NORMAL_MRF_H
11 #include <boost/shared_array.hpp>
35 boost::shared_array< float >
const& depths,
38 double const voxelSize,
39 double const observationPrecision,
40 double const gradientPrecision,
41 double const minimumEdgeDelta,
42 double const maximumEdgeDelta,
43 unsigned int const coarseness = 0
52 inline void SmoothGlobal();
53 inline void SmoothLocal();
55 inline unsigned int Coarseness()
const;
58 void CalculateNormals(
69 typedef std::pair< double, Vector< double, 2 > > State;
72 void SmoothHorizontal(
bool const odd,
bool const decreasing );
73 void SmoothVertical(
bool const odd,
bool const decreasing );
74 void SmoothCardinalCheckerboard(
bool const odd );
75 void SmoothDiagonalCheckerboard(
bool const odd );
77 void InitializeStates();
84 double m_observationPrecision;
85 double m_gradientPrecision;
86 double m_minimumEdgeDelta;
87 double m_maximumEdgeDelta;
88 unsigned int m_coarseness;
90 boost::shared_array< float > m_depths;
91 std::unique_ptr< State[] > m_states;
102 NormalMRF::NormalMRF(
103 boost::shared_array< float >
const& depths,
106 double const voxelSize,
107 double const observationPrecision,
108 double const gradientPrecision,
109 double const minimumEdgeDelta,
110 double const maximumEdgeDelta,
111 unsigned int const coarseness
113 m_dimension( dimension ),
115 m_voxelSize( voxelSize ),
116 m_observationPrecision( observationPrecision *
Square( spread ) ),
117 m_gradientPrecision( gradientPrecision ),
118 m_minimumEdgeDelta( minimumEdgeDelta ),
119 m_maximumEdgeDelta( maximumEdgeDelta ),
120 m_coarseness( coarseness ),
122 m_states( new State[ m_dimension.Product() ] )
124 assert( ( m_dimension[ 0 ] > 0 ) && ( m_dimension[ 1 ] > 0 ) );
126 assert( m_spread > 0 );
127 assert( m_voxelSize > 0 );
128 assert( m_observationPrecision > 0 );
129 assert( m_gradientPrecision > 0 );
130 assert( ( m_minimumEdgeDelta >= 0 ) && ( m_maximumEdgeDelta > m_minimumEdgeDelta ) );
133 for ( ; ( m_coarseness > 0 ) && ( ( 1u << m_coarseness ) >= dimension.
Minimum() ); --m_coarseness );
145 void NormalMRF::Refine() {
147 assert( m_coarseness > 0 );
150 SmoothDiagonalCheckerboard(
true );
151 SmoothCardinalCheckerboard(
true );
155 void NormalMRF::SmoothGlobal() {
157 SmoothHorizontal(
false,
false );
158 SmoothHorizontal(
true,
true );
159 SmoothVertical(
false,
false );
160 SmoothVertical(
true,
true );
161 SmoothHorizontal(
false,
true );
162 SmoothHorizontal(
true,
false );
163 SmoothVertical(
false,
true );
164 SmoothVertical(
true,
false );
168 void NormalMRF::SmoothLocal() {
170 SmoothCardinalCheckerboard(
false );
171 SmoothCardinalCheckerboard(
true );
175 unsigned int NormalMRF::Coarseness()
const {
191 #endif // RENDERER_DETAIL_NORMAL_MRF_H