52 #ifndef __PCL_Histogram_h
53 #define __PCL_Histogram_h
58 #include <pcl/Diagnostics.h>
100 : m_resolution(
pcl::
Max( 2, resolution ) )
102 PCL_PRECONDITION( resolution > 1 )
118 SetHistogramData( data );
153 (void)
operator =( x );
172 return m_histogram.IsEmpty();
193 return m_resolution-1;
209 PCL_PRECONDITION( resolution > 1 )
211 m_resolution =
pcl::Max( 2, resolution );
224 if ( m_histogram.IsEmpty() )
238 return m_histogram.IsEmpty() ? 0 : m_peakLevel;
247 return NormalizedLevel( PeakLevel() );
259 return m_peakLevel = m_histogram.IsEmpty() ? 0 :
260 int(
pcl::MaxItem( m_histogram.Begin(), m_histogram.End() ) - m_histogram.Begin() );
269 PCL_PRECONDITION( x >= 0 && x <= 1 )
279 PCL_PRECONDITION( i >= 0 && i < m_resolution )
280 return double(
pcl::Range( i, 0, m_resolution-1 ) )/(m_resolution - 1);
289 i = HistogramLevel( a );
290 j = HistogramLevel( b );
303 a = NormalizedLevel( i );
304 b = NormalizedLevel( j );
314 return m_histogram.Sum();
323 PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
324 if ( i < 0 || i >= m_histogram.Length() )
326 return m_histogram[i];
343 PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
344 PCL_PRECONDITION( j >= 0 && j < m_histogram.Length() )
345 if ( m_histogram.IsEmpty() )
347 i =
pcl::Range( i, 0, m_histogram.Length()-1 );
348 j =
pcl::Range( j, 0, m_histogram.Length()-1 );
351 return pcl::Sum( m_histogram.At( i ), m_histogram.At( j+1 ) );
363 return Count( m_peakLevel );
372 PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
373 PCL_PRECONDITION( j >= 0 && j < m_histogram.Length() )
374 if ( m_histogram.IsEmpty() )
376 i =
pcl::Range( i, 0, m_histogram.Length()-1 );
377 j =
pcl::Range( j, 0, m_histogram.Length()-1 );
380 return *
pcl::MaxItem( m_histogram.At( i ), m_histogram.At( j+1 ) );
395 for (
count_type s = 0; i < m_histogram.Length()-1 && (s += m_histogram[i]) <= n; ++i ) {}
406 return NormalizedLevel( ClipLow( n ) );
420 int i = m_histogram.Length();
421 for (
count_type s = 0; --i > 0 && (s += m_histogram[i]) <= n; ) {}
432 return NormalizedLevel( ClipHigh( n ) );
461 m_resolution = m_histogram.
Length();
473 PCL_PRECONDITION( where !=
nullptr )
474 PCL_PRECONDITION( fromLevel >= 0 )
475 if ( where !=
nullptr )
476 if ( !m_histogram.IsEmpty() )
478 fromLevel =
pcl::Range( fromLevel, 0, m_histogram.Length()-1 );
479 toLevel = (toLevel < 0) ? m_histogram.Length()-1 :
pcl::Range( toLevel, 0, m_histogram.Length()-1 );
480 if ( toLevel < fromLevel )
482 ::memcpy( where, m_histogram.At( fromLevel ), (1+toLevel-fromLevel)*
sizeof(
count_type ) );
502 if ( h.m_resolution == m_resolution )
506 if ( m_histogram.IsEmpty() )
512 double k = double( h.m_histogram.
Length() - 1 )/(m_histogram.Length() - 1);
513 for (
int i = 0; i < m_histogram.Length(); ++i )
532 for (
int i = 0; i < m_histogram.Length(); ++i )
533 if ( m_histogram[i] > 0 )
535 double f = double( m_histogram[i] )/n;
627 m_channel =
pcl::Max( -1, channel );
643 histogram_type m_histogram;
644 int m_resolution = 0x10000L;
Implements a generic, two-dimensional, shared or local image.
A generic rectangle in the two-dimensional space.
int Length() const noexcept
Discrete image histogram function.
int HistogramLevel(double x) const
void GetHistogramRange(int &i, int &j, double a, double b) const
void Assign(const Histogram &x)
count_type PeakCount(int i, int j) const
count_type Count(int i) const
Histogram(int resolution=0x10000L)
void GetData(count_type *where, int fromLevel=0, int toLevel=-1) const
int SelectedChannel() const
count_type Count(int i, int j) const
void SetHistogramData(const histogram_type &data)
void ClearSelectedChannel()
const Rect & SelectedRectangle() const
int ClipLow(count_type n) const
double NormalizedClipLow(count_type n) const
int ClipHigh(count_type n) const
double NormalizedPeakLevel() const
void SelectRectangle(const Rect &r)
count_type PeakCount() const
Histogram(const histogram_type &data)
const histogram_type & HistogramData() const
Histogram(const Histogram &)=default
void SetResolution(int resolution)
void Resample(Histogram &h) const
double NormalizedLevel(int i) const
void SelectChannel(int channel)
void GetNormalizedRange(double &a, double &b, int i, int j) const
double NormalizedClipHigh(count_type n) const
Histogram(Histogram &&)=default
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
A process using multiple concurrent execution threads.
High-level interface to a PixInsight view object.
Array< T, A > & operator<<(Array< T, A > &x, const V &v)
Complex< T > Log(const Complex< T > &c) noexcept
int RoundInt(T x) noexcept
void Swap(GenericPoint< T > &p1, GenericPoint< T > &p2) noexcept
unsigned long long uint64
double Sum(const T *__restrict__ i, const T *__restrict__ j) noexcept
size_type Count(FI i, FI j, const T &v) 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
FI MaxItem(FI i, FI j) noexcept