52 #ifndef __PCL_DisplayFunction_h
53 #define __PCL_DisplayFunction_h
58 #include <pcl/Diagnostics.h>
71 #define __PCL_AUTOSTRETCH_DEFAULT_CLIP -2.80
76 #define __PCL_AUTOSTRETCH_DEFAULT_TBGD 0.25
82 #define __PCL_AUTOSTRETCH_DEFAULT_LINK false
101 : m_m( 4 ), m_s( 4 ), m_h( 4 ), m_l( 4 ), m_r( 4 )
125 DisplayFunction(
const V& m,
const V& s,
const V& h,
const V& l = V(),
const V& r = V() )
126 : m_m( 4 ), m_s( 4 ), m_h( 4 ), m_l( 4 ), m_r( 4 )
129 for (
int i = 0; i < 4 && i < int( m.Length() ); ++i ) m_m[i] =
Range(
double( m[i] ), 0.0, 1.0 );
130 for (
int i = 0; i < 4 && i < int( s.Length() ); ++i ) m_s[i] =
Range(
double( s[i] ), 0.0, 1.0 );
131 for (
int i = 0; i < 4 && i < int( h.Length() ); ++i ) m_h[i] =
Range(
double( h[i] ), 0.0, 1.0 );
132 for (
int i = 0; i < 4 && i < int( l.Length() ); ++i ) m_l[i] =
Max( 0.0,
double( l[i] ) );
133 for (
int i = 0; i < 4 && i < int( r.Length() ); ++i ) m_r[i] =
Min( 1.0,
double( r[i] ) );
134 for (
int i = 0; i < 4; ++i )
135 if ( m_h[i] < m_s[i] )
176 PCL_PRECONDITION( 0 <= i && i < 4 )
177 PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
178 if ( i >= 0 && i < 4 )
214 m = m_m; s = m_s; h = m_h; l = m_l; r = m_r;
226 PCL_PRECONDITION( 0 <= i && i < 4 )
227 PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
228 return i >= 0 && i < 4 && m_m[i] == 0.5 && m_s[i] == 0 && m_h[i] == 1 && m_l[i] == 0 && m_r[i] == 1;
240 return IsIdentityTransformation( 0 )
241 && IsIdentityTransformation( 1 )
242 && IsIdentityTransformation( 2 )
243 && IsIdentityTransformation( 3 );
277 void SetTargetBackground(
double tbkg )
279 m_tbkg =
Range( tbkg, 0.0, 1.0 );
329 PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
331 if ( sigma.IsEmpty() || center.IsEmpty() )
337 int n = (sigma.Length() < 3 || center.Length() < 3) ? 1 : 3;
349 int invertedChannels = 0;
350 for (
int i = 0; i < n; ++i )
351 if ( center[i] > 0.5 )
355 if ( invertedChannels < n )
358 for (
int i = 0; i < n; ++i )
360 if ( 1 + sigma[i] != 1 )
361 c += center[i] + m_clip * sigma[i];
364 m_s[0] = m_s[1] = m_s[2] =
Range( c/n, 0.0, 1.0 );
366 m_l[0] = m_l[1] = m_l[2] = 0.0;
367 m_h[0] = m_h[1] = m_h[2] = m_r[0] = m_r[1] = m_r[2] = 1.0;
372 for (
int i = 0; i < n; ++i )
374 c += (1 + sigma[i] != 1) ? center[i] - m_clip * sigma[i] : 1.0;
377 m_h[0] = m_h[1] = m_h[2] =
Range( c/n, 0.0, 1.0 );
379 m_s[0] = m_s[1] = m_s[2] = m_l[0] = m_l[1] = m_l[2] = 0.0;
380 m_r[0] = m_r[1] = m_r[2] = 1.0;
389 for (
int i = 0; i < n; ++i )
390 if ( center[i] < 0.5 )
393 m_s[i] = (1 + sigma[i] != 1) ?
Range( center[i] + m_clip * sigma[i], 0.0, 1.0 ) : 0.0;
396 m_h[i] = m_r[i] = 1.0;
401 m_h[i] = (1 + sigma[i] != 1) ?
Range( center[i] - m_clip * sigma[i], 0.0, 1.0 ) : 1.0;
403 m_s[i] = m_l[i] = 0.0;
442 double m_clip = __PCL_AUTOSTRETCH_DEFAULT_CLIP;
443 double m_tbkg = __PCL_AUTOSTRETCH_DEFAULT_TBGD;
444 bool m_link = __PCL_AUTOSTRETCH_DEFAULT_LINK;
Adaptive histogram transformations for image visualization.
Array< HistogramTransformation > HistogramTransformations() const
bool IsIdentityTransformation(int i) const
friend void Swap(DisplayFunction &x, DisplayFunction &y)
bool IsIdentityTransformation() const
DisplayFunction(const V &m, const V &s, const V &h, const V &l=V(), const V &r=V())
void ComputeAutoStretch(const V &sigma, const V ¢er)
double TargetBackground() const
DisplayFunction(const DisplayFunction &)=default
~DisplayFunction() override
void GetDisplayFunctionParameters(V &m, V &s, V &h, V &l, V &r) const
DisplayFunction(DisplayFunction &&)=default
double ClippingPoint() const
void SetClippingPoint(double clip)
void SetLinkedRGB(bool link=true)
Implements a generic, two-dimensional, shared or local image.
Generic vector of arbitrary length.
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
constexpr const T & Min(const T &a, const T &b) noexcept
constexpr const T & Range(const T &x, const T &a, const T &b) noexcept
constexpr const T & Max(const T &a, const T &b) noexcept
void Apply(FI i, FI j, F f) noexcept(noexcept(f))