1 #include "JointHistogram.hh"
2 #include <Base/Math/Random.hh>
3 #include <Filter/Gauss.hh>
8 template<
class StorageType>
13 template<
class StorageType>
22 unsigned int nrOfSamples)
25 dNumberOfSamples_ = nrOfSamples;
36 BIASERR(
"Give Images of equal dimension!");
45 if(!histImage_.IsEmpty() || !nrImage_.IsEmpty() ){
50 float min1,max1,min2,max2;
51 gaussImage1_.GetMinMaxPixelValue(min1,max1);
52 gaussImage2_.GetMinMaxPixelValue(min2,max2);
54 if(min2>min1) min1=min2;
55 if(max2>max1) max1=max2;
57 histImage_.Init((
unsigned int)(rint(max1+1)),(
unsigned int)(rint(max1+1)),1);
58 nrImage_.Init((
unsigned int)(rint(max1+1)),(
unsigned int)(rint(max1+1)),1);
63 float ** idaNr = NULL;
65 ida1 = gaussImage1_.GetImageDataArray();
66 ida2 = gaussImage2_.GetImageDataArray();
67 idaNr = nrImage_.GetImageDataArray();
68 idaH = histImage_.GetImageDataArray();
72 for(
unsigned int i=0;i<dNumberOfSamples_;i++){
76 float pixel1=0.0,pixel2=0.0;
77 pixel1 = ida1[coordsTmp[1]][coordsTmp[0]];
78 pixel2 = ida2[coordsTmp[1]][coordsTmp[0]];
80 idaH[(
unsigned int)(pixel1)][(
unsigned int)(pixel2)]+=1.0;
81 idaNr[(
unsigned int)(pixel1)][(
unsigned int)(pixel2)] +=1.0;
102 BIASERR(
"Give Images of equal dimension!");
106 if(!histImage_.IsEmpty())
107 histImage_.Release();
109 StorageType min1,max1,min2,max2;
113 if(min2>min1) min1=min2;
114 if(max2>max1) max1=max2;
116 if(!histImage_.IsEmpty())
117 histImage_.Release();
118 histImage_.Init((
unsigned int)(max1+1),(
unsigned int)(max1+1),1);
120 float ** idaHist = histImage_.GetImageDataArray();
127 for(
unsigned int x=0;x< dWidth_;x++){
128 for(
unsigned int y=0;y< dHeight_;y++){
130 idaHist[(
unsigned int)(ida1[y][x])][(
unsigned int)(ida2[y][x])]+=1.0;
134 drawImage_ = histImage_;
149 unsigned int width = histImage_.GetWidth();
150 unsigned int height = histImage_.GetHeight();
152 float ** idaHist = histImage_.GetImageDataArray();
154 for(
unsigned int x=0;x< width;x++){
155 for(
unsigned int y=0;y< height;y++){
157 if(idaHist[y][x] != 0.0){
158 entropy += (idaHist[y][x]*log(idaHist[y][x]));
169 unsigned int width = histImage_.GetWidth();
170 unsigned int height = histImage_.GetHeight();
172 float ** idaHist = histImage_.GetImageDataArray();
174 for(
unsigned int x=0;x< width;x++){
175 for(
unsigned int y=0;y< height;y++){
177 if(idaHist[y][x] != 0.0){
178 entropy += pow((
float)idaHist[y][x],(
float)alpha);
183 return (
float)( (1/(1-alpha))*log(entropy) );
189 unsigned int width = histImage_.GetWidth();
190 unsigned int height = histImage_.GetHeight();
192 float ** idaHist = histImage_.GetImageDataArray();
193 float ** idaNr = nrImage_.GetImageDataArray();
194 for(
unsigned int x=0;x< width;x++){
195 for(
unsigned int y=0;y< height;y++){
196 if(idaNr[(
int)y][(
int)x] != 0.0)
197 idaHist[y][x] /= idaNr[(int)y][(
int)x]*dNumberOfSamples_;
198 else if(idaHist[y][x] != 0.0)
199 idaHist[y][x] /=dNumberOfSamples_;
207 unsigned int width = histImage_.GetWidth();
208 unsigned int height = histImage_.GetHeight();
210 float ** idaHist = histImage_.GetImageDataArray();
212 for(
unsigned int x=0;x< width;x++){
213 for(
unsigned int y=0;y< height;y++){
214 idaHist[y][x] /= (float)pixelCount_;
219 #define INST(type) template class JointHistogram<type>;
virtual int Filter7x7Grey(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
fast, approximate, direct implementation, ignoring wrap-arounds, roi is updated but ignored ...
void GetMinMaxPixelValue(StorageType &min, StorageType &max, unsigned short int channel=0, unsigned int *mincoo=NULL, unsigned int *maxcoo=NULL) const
returns the minimal and maximal pixel value in channel only Finds minimum and maximum pixel value in ...
unsigned int GetWidth() const
int GetUniformDistributedInt(const int min, const int max)
get uniform distributed random variable including min/max
smoothing with gaussian kernel
void Draw(BIAS::Image< float > &image)
float CalcShannonEntropy()
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
int Compute(BIAS::Image< StorageType > &image1, BIAS::Image< StorageType > &image2)
unsigned int GetHeight() const
The image template class for specific storage types.
float CalcRenyiEntropy(double alpha)
int ComputeParzenWindow(BIAS::Image< StorageType > &image1, BIAS::Image< StorageType > &image2, unsigned int nrOfSamples)
class for producing random numbers from different distributions
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase