Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BIAS::ColorHistogram< StorageType > Class Template Reference

This Class handels Histogram matters on Images. More...

#include <Image/ColorHistogram.hh>

+ Inheritance diagram for BIAS::ColorHistogram< StorageType >:
+ Collaboration diagram for BIAS::ColorHistogram< StorageType >:

Public Member Functions

double CalcSimilarity (const BIAS::ColorHistogram< StorageType > chist) const
 Calculates the Bhattacharyya similarity Coeiffient^2 which is the distance or difference of 2 colorhistograms. More...
 
double CalcSimilarity (const BIAS::ColorHistogram< StorageType > chist, double &weight) const
 Calculates the Bhattacharyya similarity Coeiffient^2 which is the distance or difference of 2 colorhistograms. More...
 
int CheckImageQuality (float percent, float &shutter, float &gain)
 checks the image quality depending on the given Histogram and increases ,decreases shutter and gain More...
 
int CheckImageQualityComplete (float percent, float &shutter, float &gain)
 same as above but luminance vector is created form all pixels in histogram More...
 
int CheckImageQualityRef (ColorHistogram< StorageType > &cHist, float percent, float &shutter, float &gain)
 same as above but checks similarity of luminance to a given reference histogram More...
 
int Clear ()
 Deletes current Histogram information. More...
 
 ColorHistogram ()
 std Con-/Destructor More...
 
void Dump (std::ostream &os=std::cout)
 dumps information on histogram More...
 
void DumpCSV (std::ostream &os=std::cout)
 dumps information on histogram to ostream format: binsize tab ux tab uy tab lx tab ly hs histogram, as a matrix with binsize x binsize (tab separated) l values as a line with lenght binsize (tab separated) More...
 
int GenerateCircleHist (BIAS::Image< StorageType > &image, int x, int y, int r)
 calcluates the cirlce formed histogram from data and adds them to the internal data structures More...
 
int GenerateCircleHist (BIAS::Image< StorageType > &image)
 calculates the Histogram of the image in circle format ATTENTION: ROI must be set in upper function SetCROI if this function is used More...
 
template<>
int GenerateCircleHist (Image< unsigned char > &img)
 
int GenerateHist (BIAS::Image< StorageType > &image, int ux, int uy, int lx, int ly)
 calcluates the histogram from data and adds them to the internal data structures More...
 
int GenerateHist (BIAS::Image< StorageType > &image)
 calculates the Histogram of the image ATTENTION: ROI must be set in upper function SetROI if this function is used More...
 
template<>
int GenerateHist (Image< unsigned char > &img)
 
char * GetBinaryData (int &length)
 
int GetBinSize () const
 GetBinSize. More...
 
int GetBinSizeSat () const
 GetBinSizeSat. More...
 
int GetHeightROI () const
 
std::vector< std::vector
< double > > 
GetHist () const
 return the histogram with H&S values More...
 
std::vector< double > GetHistL () const
 return the L-values of the HSLcolorspace that are <MINSAT in the ROI More...
 
int GetNumberOfEntries ()
 this calculates of binsize, binsizesat (1 each) coords (4) the matrix (nrofbinssat * nrofbins) lvector (nrofbins) luminance vector (nrofbins) total pixelcount (1) More...
 
void GetROI (std::vector< int > &roi) const
 
float GetSaturatedBins () const
 
returns the percentage [0..1] of HS-bins in the histogram 

that have values unequal to zero More...

 
int GetWidthROI () const
 
int Read (const char *filename)
 reads a histogram from instream and fills the internal data structures More...
 
void ReadBinaryData (char *data)
 
int SetBinSize (int binsize)
 set the binsize (must be divideable by 2pown) More...
 
int SetBinSize (int binSizeHue, int binSizeSat)
 set the binsize for different binSizes (must be divideable by 2pown) More...
 
void SetExpDist (bool expdist)
 sets expDist_ true or false, used to calculate the dist in CalcSimilarity More...
 
void SetLambda (int lambda)
 sets Lambda, which is used to calculate the dist in CalcSimilarity More...
 
void SetMinSat (int minsat)
 set minsat_, which defines the minimum saturation More...
 
int SetROI (int ux, int uy, int lx, int ly)
 set the coords for the ROI More...
 
int SetROI (int x, int y, int r)
 set the coords for the circle ROI More...
 
int Update (const BIAS::ColorHistogram< StorageType > &hist, double factor=0.5)
 
Updates the histogramm with values from hist, 

where the factor gives the weighting of the new values from hist. More...

 
 ~ColorHistogram ()
 

Public Attributes

std::vector< double > luminance_
 

Protected Member Functions

int DeleteHist_ ()
 deletes hist_, histl_... More...
 
void Normalise_ ()
 Normalizes the histogram to be able to use it in the Bhattacharyya... More...
 

Protected Attributes

unsigned int binCount_
 
int binSize_
 
int binSizeSat_
 
bool circle_
 
bool expDist_
 
std::vector< std::vector
< double > > 
hist_
 
unsigned short int histCount_
 
std::vector< double > histl_
 
BIAS::Image< StorageType > * image_
 
int lambda_
 
int lx_
 
int ly_
 
double maxBinVal_
 
double minBinVal_
 
int minSat_
 
int mx_
 
int my_
 
bool normalised_
 
int r_
 
int shift_
 
int shiftLum_
 
int shiftSat_
 
int ux_
 
int uy_
 

Detailed Description

template<class StorageType>
class BIAS::ColorHistogram< StorageType >

This Class handels Histogram matters on Images.

It represents an histogram and offers basic methods on histograms.

Author
Ingo Schiller Histogram is represented in HSL by an double vector + vector for L values tested

Definition at line 54 of file ColorHistogram.hh.

Constructor & Destructor Documentation

template<class StorageType >
BIAS::ColorHistogram< StorageType >::ColorHistogram ( )

std Con-/Destructor

This class creates a Histogram in the HSL color space.

Author
ingo schiller
Date
feb 2004

Definition at line 51 of file ColorHistogram.cpp.

template<class StorageType >
BIAS::ColorHistogram< StorageType >::~ColorHistogram ( )

Definition at line 67 of file ColorHistogram.cpp.

Member Function Documentation

template<class StorageType>
double BIAS::ColorHistogram< StorageType >::CalcSimilarity ( const BIAS::ColorHistogram< StorageType >  chist) const

Calculates the Bhattacharyya similarity Coeiffient^2 which is the distance or difference of 2 colorhistograms.

Parameters
thechist to compare with
Returns
double value, which indicates the similarity. 1 if similar.
Author
schiller March 2004

Definition at line 561 of file ColorHistogram.cpp.

References BIAS::ColorHistogram< StorageType >::hist_, and BIAS::ColorHistogram< StorageType >::histl_.

template<class StorageType>
double BIAS::ColorHistogram< StorageType >::CalcSimilarity ( const BIAS::ColorHistogram< StorageType >  chist,
double &  weight 
) const

Calculates the Bhattacharyya similarity Coeiffient^2 which is the distance or difference of 2 colorhistograms.

returns a weight, which is in [0..1] and is the percentage of the bins unequal zero.

Parameters
thechist to compare with
Returns
double value, which indicates the similarity. 1 if similar.
Author
grest May 2004

Definition at line 588 of file ColorHistogram.cpp.

References BIAS::ColorHistogram< StorageType >::hist_, and BIAS::ColorHistogram< StorageType >::histl_.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::CheckImageQuality ( float  percent,
float &  shutter,
float &  gain 
)

checks the image quality depending on the given Histogram and increases ,decreases shutter and gain

Parameters
percent= percentage of pixels in the luminance vector required
hist= the colorhistogram of the interesting part of the image
shutter= shutter value
gain= gain value
Returns
-1 if lum too high , 1 if lum too low , 0 if lum is good
Author
schiller

Definition at line 751 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::CheckImageQualityComplete ( float  percent,
float &  shutter,
float &  gain 
)

same as above but luminance vector is created form all pixels in histogram

Returns
-1 if lum too high , 1 if lum too low , 0 if lum is good

Definition at line 723 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::CheckImageQualityRef ( ColorHistogram< StorageType > &  cHist,
float  percent,
float &  shutter,
float &  gain 
)

same as above but checks similarity of luminance to a given reference histogram

Parameters
cHist= the reference colorHistogram
Returns
-1 if lum too high , 1 if lum too low , 0 if lum is good

Definition at line 659 of file ColorHistogram.cpp.

References BIAS::ColorHistogram< StorageType >::luminance_, BIAS::maxGain, BIAS::maxShutter, BIAS::minGain, and BIAS::minShutter.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::Clear ( )

Deletes current Histogram information.

Definition at line 220 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::DeleteHist_ ( )
protected

deletes hist_, histl_...

Definition at line 946 of file ColorHistogram.cpp.

template<class StorageType >
void BIAS::ColorHistogram< StorageType >::Dump ( std::ostream &  os = std::cout)

dumps information on histogram

dumps information on histogram to ostream format: binsize tab ux tab uy tab lx tab ly hs histogram, as a matrix with binsize x binsize (tab separated) l values as a line with lenght binsize (tab separated)

Parameters
os= the outstream, default std::cout
Author
Schiller

Definition at line 830 of file ColorHistogram.cpp.

template<class StorageType >
void BIAS::ColorHistogram< StorageType >::DumpCSV ( std::ostream &  os = std::cout)

dumps information on histogram to ostream format: binsize tab ux tab uy tab lx tab ly hs histogram, as a matrix with binsize x binsize (tab separated) l values as a line with lenght binsize (tab separated)

Definition at line 798 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GenerateCircleHist ( BIAS::Image< StorageType > &  image,
int  x,
int  y,
int  r 
)

calcluates the cirlce formed histogram from data and adds them to the internal data structures

Author
jpalic
Parameters
image= the image
x= middle point x of region of interest as circle
y= middly point y of region of interest as circle
r= radius of the circle

Definition at line 256 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GenerateCircleHist ( BIAS::Image< StorageType > &  image)

calculates the Histogram of the image in circle format ATTENTION: ROI must be set in upper function SetCROI if this function is used

Parameters
image= the image
Returns
-1 if image does not exist

Definition at line 425 of file ColorHistogram.cpp.

References BIAS::ImageBase::CM_HSL, BIAS::ImageBase::GetColorModel(), and BIAS::BresenhamCircle::GetNext().

template<>
int BIAS::ColorHistogram< unsigned char >::GenerateCircleHist ( Image< unsigned char > &  img)
template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GenerateHist ( BIAS::Image< StorageType > &  image,
int  ux,
int  uy,
int  lx,
int  ly 
)

calcluates the histogram from data and adds them to the internal data structures

Author
schiller
Parameters
image= the image
ux= upper left corner x of region of interest
uy= upper left corner y of region of interest
lx= lower right corner x of region of interest
ly= lower right corner y of region of interest

Definition at line 240 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GenerateHist ( BIAS::Image< StorageType > &  image)

calculates the Histogram of the image ATTENTION: ROI must be set in upper function SetROI if this function is used

Parameters
image= the image
Returns
-1 if image does not exist

Definition at line 272 of file ColorHistogram.cpp.

References BIAS::ImageBase::CM_HSL, and BIAS::ImageBase::GetColorModel().

template<>
int BIAS::ColorHistogram< unsigned char >::GenerateHist ( Image< unsigned char > &  img)
template<class StorageType >
char * BIAS::ColorHistogram< StorageType >::GetBinaryData ( int &  length)

Definition at line 975 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GetBinSize ( ) const
inline

GetBinSize.

Returns
the binSize of Hue and light

Definition at line 112 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::GetBinSizeSat ( ) const
inline

GetBinSizeSat.

Returns
the binSize of Sat

Definition at line 118 of file ColorHistogram.hh.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::GetHeightROI ( ) const
Returns
the Height of the ROI

Definition at line 188 of file ColorHistogram.cpp.

Referenced by BIAS::CondensHisto::SetReferenceHistogram().

template<class StorageType >
std::vector< std::vector< double > > BIAS::ColorHistogram< StorageType >::GetHist ( ) const

return the histogram with H&S values

Definition at line 175 of file ColorHistogram.cpp.

Referenced by BIAS::IntegralHistogram::CalcSimilarity().

template<class StorageType >
std::vector< double > BIAS::ColorHistogram< StorageType >::GetHistL ( ) const

return the L-values of the HSLcolorspace that are <MINSAT in the ROI

Definition at line 182 of file ColorHistogram.cpp.

Referenced by BIAS::IntegralHistogram::CalcSimilarity().

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::GetNumberOfEntries ( )

this calculates of binsize, binsizesat (1 each) coords (4) the matrix (nrofbinssat * nrofbins) lvector (nrofbins) luminance vector (nrofbins) total pixelcount (1)

Returns
the length of a dumped ColorHistogram
Author
Ingo Schiller

Definition at line 865 of file ColorHistogram.cpp.

template<class StorageType >
void BIAS::ColorHistogram< StorageType >::GetROI ( std::vector< int > &  roi) const
Returns
the coords of ROI in an array

Definition at line 201 of file ColorHistogram.cpp.

template<class StorageType >
float BIAS::ColorHistogram< StorageType >::GetSaturatedBins ( ) const

returns the percentage [0..1] of HS-bins in the histogram 

that have values unequal to zero

Author
grest, Mar 2005

Definition at line 959 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::GetWidthROI ( ) const
Returns
the width of the ROI

Definition at line 194 of file ColorHistogram.cpp.

Referenced by BIAS::CondensHisto::SetReferenceHistogram().

template<class StorageType >
void BIAS::ColorHistogram< StorageType >::Normalise_ ( )
protected

Normalizes the histogram to be able to use it in the Bhattacharyya...

Difference

Definition at line 921 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::Read ( const char *  filename)

reads a histogram from instream and fills the internal data structures

Parameters
is= the instream
Author
Schiller March 2004
Returns
0 if ok, -1 if no file

Definition at line 876 of file ColorHistogram.cpp.

template<class StorageType >
void BIAS::ColorHistogram< StorageType >::ReadBinaryData ( char *  data)

Definition at line 1012 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::SetBinSize ( int  binsize)

set the binsize (must be divideable by 2pown)

Definition at line 101 of file ColorHistogram.cpp.

Referenced by BIAS::CondensHisto::SetReferenceHistogram().

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::SetBinSize ( int  binSizeHue,
int  binSizeSat 
)

set the binsize for different binSizes (must be divideable by 2pown)

Definition at line 132 of file ColorHistogram.cpp.

template<class StorageType>
void BIAS::ColorHistogram< StorageType >::SetExpDist ( bool  expdist)
inline

sets expDist_ true or false, used to calculate the dist in CalcSimilarity

Definition at line 105 of file ColorHistogram.hh.

template<class StorageType>
void BIAS::ColorHistogram< StorageType >::SetLambda ( int  lambda)
inline

sets Lambda, which is used to calculate the dist in CalcSimilarity

Definition at line 99 of file ColorHistogram.hh.

template<class StorageType>
void BIAS::ColorHistogram< StorageType >::SetMinSat ( int  minsat)
inline

set minsat_, which defines the minimum saturation

Definition at line 92 of file ColorHistogram.hh.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::SetROI ( int  ux,
int  uy,
int  lx,
int  ly 
)

set the coords for the ROI

Definition at line 75 of file ColorHistogram.cpp.

template<class StorageType >
int BIAS::ColorHistogram< StorageType >::SetROI ( int  x,
int  y,
int  r 
)

set the coords for the circle ROI

Definition at line 89 of file ColorHistogram.cpp.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::Update ( const BIAS::ColorHistogram< StorageType > &  hist,
double  factor = 0.5 
)

Updates the histogramm with values from hist, 

where the factor gives the weighting of the new values from hist.

Returns
0 in case of no error
Author
Daniel Grest, March 2004

Definition at line 628 of file ColorHistogram.cpp.

References BIAS::ColorHistogram< StorageType >::binSize_, BIAS::ColorHistogram< StorageType >::hist_, BIAS::ColorHistogram< StorageType >::histl_, BIAS::ColorHistogram< StorageType >::lx_, BIAS::ColorHistogram< StorageType >::ly_, BIAS::ColorHistogram< StorageType >::ux_, and BIAS::ColorHistogram< StorageType >::uy_.

Member Data Documentation

template<class StorageType>
unsigned int BIAS::ColorHistogram< StorageType >::binCount_
protected

Definition at line 319 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::binSize_
protected

Definition at line 332 of file ColorHistogram.hh.

Referenced by BIAS::ColorHistogram< StorageType >::Update().

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::binSizeSat_
protected

Definition at line 333 of file ColorHistogram.hh.

template<class StorageType>
bool BIAS::ColorHistogram< StorageType >::circle_
protected

Definition at line 327 of file ColorHistogram.hh.

template<class StorageType>
bool BIAS::ColorHistogram< StorageType >::expDist_
protected

Definition at line 338 of file ColorHistogram.hh.

template<class StorageType>
std::vector<std::vector<double> > BIAS::ColorHistogram< StorageType >::hist_
protected
template<class StorageType>
unsigned short int BIAS::ColorHistogram< StorageType >::histCount_
protected

Definition at line 318 of file ColorHistogram.hh.

template<class StorageType>
std::vector<double> BIAS::ColorHistogram< StorageType >::histl_
protected
template<class StorageType>
BIAS::Image<StorageType>* BIAS::ColorHistogram< StorageType >::image_
protected

Definition at line 320 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::lambda_
protected

Definition at line 337 of file ColorHistogram.hh.

template<class StorageType>
std::vector<double> BIAS::ColorHistogram< StorageType >::luminance_
template<class StorageType>
int BIAS::ColorHistogram< StorageType >::lx_
protected

Definition at line 324 of file ColorHistogram.hh.

Referenced by BIAS::ColorHistogram< StorageType >::Update().

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::ly_
protected

Definition at line 324 of file ColorHistogram.hh.

Referenced by BIAS::ColorHistogram< StorageType >::Update().

template<class StorageType>
double BIAS::ColorHistogram< StorageType >::maxBinVal_
protected

Definition at line 329 of file ColorHistogram.hh.

template<class StorageType>
double BIAS::ColorHistogram< StorageType >::minBinVal_
protected

Definition at line 329 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::minSat_
protected

Definition at line 337 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::mx_
protected

Definition at line 325 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::my_
protected

Definition at line 325 of file ColorHistogram.hh.

template<class StorageType>
bool BIAS::ColorHistogram< StorageType >::normalised_
protected

Definition at line 316 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::r_
protected

Definition at line 325 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::shift_
protected

Definition at line 334 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::shiftLum_
protected

Definition at line 336 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::shiftSat_
protected

Definition at line 335 of file ColorHistogram.hh.

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::ux_
protected

Definition at line 324 of file ColorHistogram.hh.

Referenced by BIAS::ColorHistogram< StorageType >::Update().

template<class StorageType>
int BIAS::ColorHistogram< StorageType >::uy_
protected

Definition at line 324 of file ColorHistogram.hh.

Referenced by BIAS::ColorHistogram< StorageType >::Update().


The documentation for this class was generated from the following files: