Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HistogramImage.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #include "HistogramImage.hh"
27 
28 #include <Base/Image/ImageBase.hh>
29 #include <Base/ImageUtils/ImageDraw.hh>
30 
31 #include <Base/Common/BIASpragma.hh>
32 
33 using namespace std;
34 
35 namespace BIAS
36 {
37 
38 
39 
40 
41 HistogramImage::HistogramImage(unsigned short int size)
42 {
43  ColorModel_ = ImageBase::CM_RGB;
44  BinCount_ = 256;
45  InterleavedDataOrder_ = true;
46  HistCount_ = 0;
47  HistSize_ = 256;
48  _uiBorder = 2;
49  _ucBorderColor = 128;
50  Factor_ = size;
51  ScaleYToMaxEntry_=true;
52 
53  Hist_ = NULL;
54  Color_=NULL;
55  Average_=NULL;
56  MinBinVal_=NULL;
57  BinSize_=NULL;
58  MaxBinVal_=NULL;
59  MaxHistEntry_ = NULL;
60  NumData_ = NULL;
61 
62  NewDebugLevel("D_HIST_BIN");
63 }
64 
65 HistogramImage::~HistogramImage()
66 {
67  ReleaseHist();
68 }
69 
70 void HistogramImage::SetFactor(unsigned short Factor)
71 {
72  Factor_ = Factor;
73  InitHist(BinCount_, HistCount_);
74 }
75 
76 void HistogramImage::SetColorModel()
77 {
78  BIASERR("HistogramImage::SetColorModel() not valid for HistogramImage");
79 }
80 
81 
82 void HistogramImage::SetBinCount(unsigned int bincount)
83 {
84  if (bincount != BinCount_){
85  InitHist(bincount, HistCount_);
86  }
87 }
88 
89 
90 void HistogramImage::SetHistCount(unsigned int histcount)
91 {
92  if (histcount != HistCount_){
93  InitHist(BinCount_, histcount);
94  }
95 }
96 
97 int HistogramImage::InitHist(unsigned int bincount , unsigned int histcount)
98 {
99  int bc, hs;
100  ReleaseHist();
101  HistCount_ = histcount;
102  BinCount_ = bincount;
103  Hist_ = new double*[HistCount_];
104  Color_ = new unsigned char*[HistCount_];
105  MinBinVal_ = new double[HistCount_];
106  MaxBinVal_ = new double[HistCount_];
107  BinSize_ = new double[HistCount_];
108  MaxHistEntry_ = new double[HistCount_];
109  NumData_ = new double[HistCount_];
110  Average_ = new double[HistCount_];
111  for (register unsigned int i = 0; i < HistCount_; i++){
112  Hist_[i] = new double[BinCount_];
113  for (register unsigned int j = 0; j < BinCount_; j++){
114  Hist_[i][j] = 0.0;
115  }
116  Color_[i] = new unsigned char[3];
117  // deafult Color is black
118  for (register int j = 0; j < 3; j++){
119  Color_[i][j] = 0;
120  }
121  MinBinVal_[i]=DBL_MAX;
122  MaxHistEntry_[i]=MaxBinVal_[i]=-DBL_MAX;
123  NumData_[i]=0.0;
124  Average_[i]=0.0;
125  }
126 
127  // image width and height must be dividable by 4
128  if (BinCount_ % 4 != 0)
129  bc = BinCount_ + 4 - (BinCount_ % 4);
130  else
131  bc = BinCount_;
132  if (HistSize_ % 4 != 0)
133  hs = HistSize_ + 4 - (HistSize_ % 4);
134  else
135  hs = HistSize_;
136 
137  // scale image with Factor_
138  Init((bc + 2 * _uiBorder) * Factor_ , (hs + 2 * _uiBorder) * Factor_ , 3);
139  // white background
140  FillImageWithConstValue(255);
141  return 0;
142 }
143 
144 
145 int HistogramImage::ReleaseHist()
146 {
147  if (Hist_){
148  for (register int i =0; i < HistCount_; i++){
149  delete[] Hist_[i];
150  delete[] Color_[i];
151  }
152  delete[] Hist_; Hist_=NULL;
153  }
154  HistCount_=0;
155  if (Color_){ delete[] Color_; Color_=NULL; }
156  if (Average_){ delete[] Average_; Average_=NULL; }
157  if (MinBinVal_){ delete[] MinBinVal_; MinBinVal_=NULL; }
158  if (BinSize_){ delete[] BinSize_; BinSize_=NULL; }
159  if (MaxBinVal_){ delete[] MaxBinVal_; MaxBinVal_=NULL; }
160  if (MaxHistEntry_){ delete[] MaxHistEntry_; MaxHistEntry_ = NULL; }
161  if (NumData_){ delete[] NumData_; NumData_ = NULL; }
162  Release();
163  return 0;
164 }
165 
166 
167 /**
168  @brief calculates the Shannon Entropy and treats entries in HistogramImage as
169  probabilities
170  @param hist: the histogram number (default =0)
171  @author ischiller
172 */
173 float HistogramImage::CalcShannonEntropy(unsigned int hist)
174 
175 {
176  if ( hist >= HistCount_){
177  BIASERR("HistogramImage::AddHist invalid hist "<<hist);
178  return -1.0;
179  }
180  float entropy=0.0;
181  int number=0;
182 
183  for(unsigned int bin=0; bin < BinCount_-1;bin++)
184  {
185  if(Hist_[hist][bin] != 0.0)
186  {
187  entropy += (Hist_[hist][bin]/NumData_[hist])*
188  log((Hist_[hist][bin]/NumData_[hist]));
189  number++;
190  }
191  }
192  return (-1)*entropy;
193 }
194 
195 /**
196  @brief calculates the Renyi Entropy and treats entries in HistogramImage as
197  probabilities
198  @param hist: the histogram number (default =0)
199  @param alpha: parameter alpah of renyi entropy
200  @author ischiller
201 */
202 float HistogramImage::CalcRenyiEntropy(unsigned int hist, double alpha)
203 
204 {
205  if ( hist >= HistCount_){
206  BIASERR("HistogramImage::AddHist invalid hist "<<hist);
207  return -1.0;
208  }
209  float entropy=0.0;
210 
211  for(unsigned int bin=0; bin < BinCount_-1;bin++)
212  {
213  if(Hist_[hist][bin] != 0.0)
214  {
215  entropy += pow((Hist_[hist][bin]/NumData_[hist]),alpha);
216  }
217  }
218  return (1/(1-alpha))*log(entropy);
219 }
220 
221 template <class StorageType>
222 int HistogramImage::AddHist(const Image<StorageType>& Image,
223  unsigned int hist )
224 {
225 #ifdef BIAS_DEBUG
226  if (Image.GetChannelCount() != 1)
227  BIASERR("HistogramImage::AddHist only supports one channel images");
228  if ( hist >= HistCount_)
229  BIASERR("HistogramImage::AddHist invalid hist "<<hist);
230  if (Image.IsEmpty())
231  BIASERR("HistogramImage::AddHist called with empty image");
232 #endif
233  const StorageType **ImageDataArray = Image.GetImageDataArray();
234  StorageType min, max, diff;
235  int bin=0;
236  Image.GetMinMaxPixelValue(min, max);
237  diff=max-min;
238  MinBinVal_[hist]=(double)min;
239  MaxBinVal_[hist]=(double)max;
240  BinSize_[hist]=(MaxBinVal_[hist]-MinBinVal_[hist])/(double)BinCount_;
241  BCDOUT(D_HIST_BIN, "hist #"<<hist<<": min/max pixel value: "
242  <<MinBinVal_[hist]<<"/"<<MaxBinVal_[hist]<<endl);
243  const unsigned width = Image.GetWidth(), height = Image.GetHeight();
244  for (unsigned y=0; y<height; y++){
245  for (unsigned x=0; x<width;x++){
246  if (ImageDataArray[y][x]==max){
247  bin=BinCount_-1;
248  }else{
249  const ROI *r = Image.GetROI();
250  if (r->IsInROI(x,y))
251  bin=(unsigned)floor((double)BinCount_ * ((double)ImageDataArray[y][x]-MinBinVal_[hist])/(double)diff);
252  }
253 #ifdef BIAS_DEBUG
254  if (bin<0){
255  BIASERR("invalid index "<<bin);
256  BIASABORT;
257  bin = 0;
258  }
259  if (bin>=(int)BinCount_){
260  BIASERR("invalid index "<<bin<<" "
261  <<ImageDataArray[y][x]<<" "<<min<<" "<<BinSize_[hist]<<" "<<BinCount_);
262  BIASABORT;
263  bin = BinCount_-1;
264  }
265 #endif
266  Hist_[hist][bin]++;
267  if (Hist_[hist][bin]>MaxHistEntry_[hist])
268  MaxHistEntry_[hist]=Hist_[hist][bin];
269  }
270  }
271  NumData_[hist]+=(double)Image.GetPixelCount();
272  CalcAverage_(hist);
273 
274  return 0;
275 }
276 
277 template <> BIASImage_EXPORT
278 int HistogramImage::AddHist(const Image<unsigned char>& Image,
279  unsigned int hist )
280 {
281 #ifdef BIAS_DEBUG
282  if (Image.GetChannelCount() != 1)
283  BIASERR("HistogramImage::AddHist only supports one channel images");
284  if ( hist >= HistCount_)
285  BIASERR("HistogramImage::AddHist invalid hist "<<hist);
286  if (Image.IsEmpty())
287  BIASERR("HistogramImage::AddHist called with empty image");
288 #endif
289  const unsigned char **ImageDataArray = Image.GetImageDataArray();
290  const unsigned width = Image.GetWidth(), height = Image.GetHeight();
291  for (unsigned y=0; y<height; y++){
292  for (unsigned x=0; x<width;x++){
293  if (Hist_[hist][BinCount_ * ImageDataArray[y][x] / 256] + 1 > MaxHistEntry_[hist] ){
294  MaxHistEntry_[hist] = Hist_[hist][BinCount_ * (ImageDataArray[y][x]/*+1*/) / 256]++;
295  } else {
296  const ROI *r = Image.GetROI();
297  if (r->IsInROI(x,y))
298  Hist_[hist][BinCount_ * (ImageDataArray[y][x]/*+1*/) / 256]++;
299  }
300  }
301  }
302  CalcAverage_(hist);
303  MinBinVal_[hist]=0.0;
304  MaxBinVal_[hist]=255.0;
305  NumData_[hist]+=(double)Image.GetPixelCount();
306  BinSize_[hist]=(MaxBinVal_[hist]-MinBinVal_[hist])/(double)BinCount_;
307  return 0;
308 }
309 
310 
311 template <class DataType>
312 int HistogramImage::AddHist(const vector<DataType>& data, unsigned int hist)
313 {
314  typename vector<DataType>::const_iterator it;
315  DataType max=data.front(), min=data.front();
316  BIASCDOUT(D_HIST_VEC, "data.size() = "<<data.size()<<endl);
317  for (it=data.begin(); it!=data.end(); it++){
318  if ((*it)>max) max=*it;
319  if ((*it)<min) min=*it;
320  BIASCDOUT(D_HIST_VEC, (*it)<<" ");
321  }
322  BIASCDOUT(D_HIST_VEC, "\nmin/max "<<min<<"/"<<max);
323  return AddHist(data, min, max, hist);
324 }
325 
326 template <class DataType>
327 int HistogramImage::AddHist(const vector<DataType>& data, DataType min, DataType max,
328  unsigned int hist)
329 {
330 
331 
332  if (data.size()==0){
333  BIASERR("data has size 0");
334  return -1;
335  }
336  if (hist>HistCount_){
337  BIASERR("hist="<<hist<<" to big. HistCount_="<<HistCount_);
338  return -2;
339  }
340 
341  typename vector<DataType>::const_iterator it;
342  int bin;
343  BIASCDOUT(D_HIST_VEC, "data.size() = "<<data.size()<<endl);
344 
345  BIASCDOUT(D_HIST_VEC, "\nmin/max "<<min<<"/"<<max);
346  MinBinVal_[hist]=(double)min;
347  MaxBinVal_[hist]=(double)max;
348  BIASCDOUT(D_HIST_VEC, "MinBinVal_["<<hist<<"]/MaxBinVal_["<<hist<<"] "<<
349  MinBinVal_[hist]<<"/"<<MaxBinVal_[hist]);
350  BinSize_[hist]=(MaxBinVal_[hist]-MinBinVal_[hist])/(double)BinCount_;
351  BIASCDOUT(D_HIST_VEC, "min: "<<MinBinVal_[hist]<<" max: "<<MaxBinVal_[hist]
352  <<" binsize: "<<BinSize_[hist]<<endl);
353  for (it=data.begin(); it!=data.end(); it++){
354  if (*it==max){
355  bin=BinCount_-1;
356  } else {
357  bin=(int)floor(double((*it)-min)/BinSize_[hist]);
358  }
359 #ifdef BIAS_DEBUG
360  if (bin<0){
361  BIASERR("invalid index "<<bin<<" data "<<(*it)<<" min "<<min
362  <<" binsize "<<BinSize_[hist]);
363  BIASABORT;
364  }
365  if (bin>=(int)BinCount_){
366  BIASERR("invalid index "<<bin<<" "
367  <<*it<<" "<<min<<" "<<BinSize_[hist]<<" "<<BinCount_);
368  BIASABORT;
369  }
370 #endif
371  Hist_[hist][bin]++;
372  if (Hist_[hist][bin]>MaxHistEntry_[hist])
373  MaxHistEntry_[hist]=Hist_[hist][bin];
374  }
375  BIASCDOUT(D_HIST_VEC, "MaxHistEntry_["<<hist<<"] = "<<MaxHistEntry_[hist]
376  <<endl);
377  NumData_[hist]+=(double)data.size();
378  CalcAverage_(hist);
379  return 0;
380 }
381 
382 
383 
384 template <class DataType>
385 int HistogramImage::AddWeightedHist(const vector<DataType>& data,const vector<double>& weight,
386  unsigned int hist)
387 {
388 #ifdef BIAS_DEBUG
389  if (data.size() != weight.size()){
390  BIASERR("data and weight have different sizes "<<data.size()
391  <<" "<<weight.size());
392  BIASASSERT(data.size() == weight.size());
393  }
394 #endif
395  typename vector<DataType>::const_iterator it;
396  vector<double>::const_iterator wit;
397  int bin;
398  DataType max=data.front(), min=data.front();
399  for (it=data.begin(); it!=data.end(); it++){
400  if ((*it)>max) max=*it;
401  if ((*it)<min) min=*it;
402  }
403  MinBinVal_[hist]=(double)min;
404  MaxBinVal_[hist]=(double)max;
405  BinSize_[hist]=(MaxBinVal_[hist]-MinBinVal_[hist])/(double)BinCount_;
406 
407  for (it=data.begin(), wit=weight.begin(); it!=data.end(); it++, wit++){
408  if (*it==max){
409  bin=BinCount_-1;
410  } else {
411  bin=(int)floor(double((*it)-min)/BinSize_[hist]);
412  }
413 #ifdef BIAS_DEBUG
414  if (*it!=max){
415  if (bin<0)
416  BIASERR("invalid index "<<bin);
417  if (bin>=(int)BinCount_)
418  BIASERR("invalid index "<<bin<<" "
419  <<*it<<" "<<min<<" "<<BinSize_[hist]<<" "<<BinCount_);
420  }
421 #endif
422  Hist_[hist][bin]+=(*wit);
423  if (Hist_[hist][bin]>MaxHistEntry_[hist])
424  MaxHistEntry_[hist]=Hist_[hist][bin];
425  }
426 
427  NumData_[hist]+=(double)data.size();
428  CalcAverage_(hist);
429  return 0;
430 }
431 
432 template int HistogramImage::AddWeightedHist<double>(const vector<double>& data,const vector<double>& weight, unsigned hist);
433 template int HistogramImage::AddWeightedHist<float>(const vector<float>& data,const vector<double>& weight, unsigned hist);
434 template int HistogramImage::AddWeightedHist<int>(const vector<int>& data,const vector<double>& weight, unsigned hist);
435 template int HistogramImage::AddWeightedHist<unsigned>(const vector<unsigned>& data,const vector<double>& weight, unsigned hist);
436 
437 int HistogramImage::CalcAverage_(unsigned int hist)
438 {
439  Average_[hist] = 0.0;
440  for (unsigned int i=0; i<BinCount_; i++)
441  Average_[hist] += Hist_[hist][i];
442  //cerr << "sum Hist["<<hist<<"]="<<Average_[hist]<<endl;
443  Average_[hist] /= BinCount_;
444  //cerr << "average Hist["<<hist<<"]="<<Average_[hist]<<endl;
445  return 0;
446 }
447 
448 
449 
450 int HistogramImage::ZeroHist(unsigned int hist)
451 {
452  MaxHistEntry_[hist]=0.0;
453  NumData_[hist]=0.0;
454  Average_[hist]=0.0;
455  MaxBinVal_[hist]=MinBinVal_[hist]=BinSize_[hist]=0.0;
456  if (Hist_!=NULL)
457  memset(Hist_[hist], 0, BinCount_ * sizeof(double));
458  FillImageWithConstValue(255);
459  return 0;
460 }
461 
462 
463 int HistogramImage::RedrawHist_(unsigned int hist)
464 {
465  return DeleteHist_(hist) + DrawHist_(hist);
466 }
467 
468 
469 int HistogramImage::DrawHist_(unsigned int hist)
470 {
471  unsigned int BorderOffset = Factor_ * _uiBorder * GetChannelCount();
472  register unsigned char **ImageDataArray = GetImageDataArray();
473  unsigned start[2], end[2], st[2];
474 
475  // now draw hist
476  register int y, x, kk;
477  start[0]=Factor_ * _uiBorder;
478  start[1]=Factor_ * _uiBorder + Factor_ * (HistSize_-1);
479  double maxy=(ScaleYToMaxEntry_)?(MaxHistEntry_[hist]):(NumData_[hist]);
480  for (register unsigned int i = 0; i < BinCount_ ; i++){
481  y = Factor_ * _uiBorder + Factor_ *
482  (((int)HistSize_-1)-(int)rint(((int)HistSize_-1)*Hist_[hist][i] /
483  maxy));
484  x = BorderOffset + Factor_ * 3 * i;
485 #ifdef BIAS_DEBUG
486  if (y<0 || y>=(int)GetHeight()){
487  BIASERR("invalid y="<<y<<" HistSize_="<<HistSize_<<" Hist_["<<hist<<"]["
488  <<i<<"]="<<Hist_[hist][i]<<" MaxHistEntry_="
489  <<MaxHistEntry_[hist]);
490  BIASABORT;
491  }
492 #endif
493  switch (Mode_ ) {
494  case HIST_POINTS:
495  for (register unsigned int k = 0; k < Factor_ ; k++){
496  kk = k*3;
497  for (register unsigned int j = 0; j < Factor_ ; j++){
498  ImageDataArray[y + j][x + kk] = Color_[hist][0];
499  ImageDataArray[y + j][x + kk + 1] = Color_[hist][1];
500  ImageDataArray[y + j][x + kk + 2] = Color_[hist][2];
501  }
502  }
503  break;
504  case HIST_BARS:
505  for (register unsigned int k = 0; k < Factor_ ; k++){
506  kk = k*3;
507  for (register unsigned int j = y;
508  j < GetHeight() - Factor_ * _uiBorder; j++){
509  ImageDataArray[j][x + kk] = Color_[hist][0];
510  ImageDataArray[j][x + kk + 1] = Color_[hist][1];
511  ImageDataArray[j][x + kk + 2] = Color_[hist][2];
512  }
513  }
514  break;
515  case HIST_LINES:
516  for (register unsigned int k = 0; k < Factor_ ; k++){
517  for (register unsigned int j = 0; j < Factor_ ; j++){
518  st[0]=start[0]+k;
519  st[1]=start[1]+j;
520  end[0]=x/3+k;
521  end[1]=y+j;
522  ImageDraw<unsigned char>::Line(*this, st, end, Color_[hist]);
523  }
524  }
525  start[0]=x/3;
526  start[1]=y;
527  break;
528  }
529  }
530  // draw line of average
531  y = Factor_ * (_uiBorder + (HistSize_ - 1) -
532  (int)rint((HistSize_ - 1) * Average_[hist] /
533  maxy)) +
534  Factor_ * _uiBorder;
535  //cerr << "average of Hist_["<<hist<<"]="<<Average_[hist]<<" at "<<y<<endl;
536  for (unsigned int j=BorderOffset;
537  j < (BinCount_ - 1) * Factor_ * 3 + BorderOffset;
538  j+=3){
539  ImageDataArray[y][j] = Color_[hist][0];
540  ImageDataArray[y][j+1] = Color_[hist][1];
541  ImageDataArray[y][j+2] = Color_[hist][2];
542  }
543  return 0;
544 }
545 
546 int HistogramImage::DrawHistLog_(unsigned int hist)
547 {
548  unsigned int BorderOffset = Factor_ * _uiBorder * GetChannelCount();
549  register unsigned char **ImageDataArray = GetImageDataArray();
550  unsigned start[2], end[2], st[2];
551 
552  // now draw hist
553  register int y, x, kk;
554  start[0]=Factor_ * _uiBorder;
555  start[1]=Factor_ * _uiBorder + Factor_ * (HistSize_-1);
556  double maxy=(ScaleYToMaxEntry_)?(MaxHistEntry_[hist]):(NumData_[hist]);
557  for (register unsigned int i = 0; i < BinCount_ ; i++){
558  y = Factor_ * _uiBorder + Factor_ *
559  (((int)HistSize_-1)-
560  (int)rint(((int)HistSize_-1)*
561  log10((Hist_[hist][i]/maxy)*9.0+1.0)));
562  x = BorderOffset + Factor_ * 3 * i;
563 #ifdef BIAS_DEBUG
564  if (y<0 || y>=(int)GetHeight()){
565  BIASERR("invalid y="<<y<<" HistSize_="<<HistSize_<<" Hist_["<<hist<<"]["
566  <<i<<"]="<<Hist_[hist][i]<<" MaxHistEntry_="
567  <<MaxHistEntry_[hist]);
568  BIASABORT;
569  }
570 #endif
571  switch (Mode_ ) {
572  case HIST_POINTS:
573  for (register unsigned int k = 0; k < Factor_ ; k++){
574  kk = k*3;
575  for (register unsigned int j = 0; j < Factor_ ; j++){
576  ImageDataArray[y + j][x + kk] = Color_[hist][0];
577  ImageDataArray[y + j][x + kk + 1] = Color_[hist][1];
578  ImageDataArray[y + j][x + kk + 2] = Color_[hist][2];
579  }
580  }
581  break;
582  case HIST_BARS:
583  for (register unsigned int k = 0; k < Factor_ ; k++){
584  kk = k*3;
585  for (register unsigned int j = y;
586  j < GetHeight() - Factor_ * _uiBorder; j++){
587  ImageDataArray[j][x + kk] = Color_[hist][0];
588  ImageDataArray[j][x + kk + 1] = Color_[hist][1];
589  ImageDataArray[j][x + kk + 2] = Color_[hist][2];
590  }
591  }
592  break;
593  case HIST_LINES:
594  for (register unsigned int k = 0; k < Factor_ ; k++){
595  for (register unsigned int j = 0; j < Factor_ ; j++){
596  st[0]=start[0]+k;
597  st[1]=start[1]+j;
598  end[0]=x/3+k;
599  end[1]=y+j;
600  ImageDraw<unsigned char>::Line(*this, st, end, Color_[hist]);
601  }
602  }
603  start[0]=x/3;
604  start[1]=y;
605  break;
606  }
607  }
608  // draw line of average
609  y = Factor_ * (_uiBorder + (HistSize_ - 1) -
610  (int)rint((HistSize_ - 1) * Average_[hist] /
611  maxy)) +
612  Factor_ * _uiBorder;
613  //cerr << "average of Hist_["<<hist<<"]="<<Average_[hist]<<" at "<<y<<endl;
614  for (unsigned int j=BorderOffset;
615  j < (BinCount_ - 1) * Factor_ * 3 + BorderOffset;
616  j+=3){
617  ImageDataArray[y][j] = Color_[hist][0];
618  ImageDataArray[y][j+1] = Color_[hist][1];
619  ImageDataArray[y][j+2] = Color_[hist][2];
620  }
621  return 0;
622 }
623 
624 
625 int HistogramImage::DeleteHist_(unsigned int hist)
626 {
627  register unsigned char *r = GetImageData();
628  register unsigned char *g = r + 1;
629  register unsigned char *b = g + 1;
630  register unsigned char *end = r + GetChannelCount() * GetPixelCount();
631 
632  while (r < end){
633  if ( (*r == Color_[hist][0]) && (*g == Color_[hist][1]) &&
634  (*b == Color_[hist][2]) )
635  *r = *g = *b = 255;
636  r+=3;
637  g+=3;
638  b+=3;
639  }
640  return 0;
641 }
642 
643 
644 int HistogramImage::SetColor(unsigned char R, unsigned char G, unsigned char B,
645  unsigned int hist)
646 {
647 #ifdef BIAS_DEBUG
648  if (hist + 1 > HistCount_ )
649  BIASERR("HistogramImage::SetColor() invalid hist "<<hist);
650 #endif
651  Color_[hist][0] = R;
652  Color_[hist][1] = G;
653  Color_[hist][2] = B;
654 
655  return 0;
656 }
657 
658 
659 int HistogramImage::Draw()
660 {
661  register unsigned char **ImageDataArray = GetImageDataArray();
662  // draw border
663  for (unsigned int i=0; i< Factor_ * _uiBorder; i++){
664  memset((void *)(ImageDataArray[i]), _ucBorderColor, GetWidthStep() *
665  sizeof(unsigned char));
666  memset((void *)(ImageDataArray[GetHeight()-1-i]), _ucBorderColor,
667  GetWidthStep() * sizeof(unsigned char) );
668  for (unsigned int j=Factor_ * _uiBorder; j<GetHeight()-Factor_ * _uiBorder;
669  j++){
670  for (unsigned int c=0; c<GetChannelCount(); c++){
671  ImageDataArray[j][i*GetChannelCount()+c]=_ucBorderColor;
672  ImageDataArray[j][(GetWidth()-1-i)*GetChannelCount()+c]=_ucBorderColor;
673  }
674  }
675  }
676  for (int i = 0; i < HistCount_; i++)
677  if (MaxHistEntry_[i]>0)
678  DrawHist_(i);
679  return 0;
680 }
681 
682 int HistogramImage::DrawLog()
683 {
684  register unsigned char **ImageDataArray = GetImageDataArray();
685  // draw border
686  for (unsigned int i=0; i< Factor_ * _uiBorder; i++){
687  memset((void *)(ImageDataArray[i]), _ucBorderColor, GetWidthStep() *
688  sizeof(unsigned char));
689  memset((void *)(ImageDataArray[GetHeight()-1-i]), _ucBorderColor,
690  GetWidthStep() * sizeof(unsigned char) );
691  for (unsigned int j=Factor_ * _uiBorder; j<GetHeight()-Factor_ * _uiBorder;
692  j++){
693  for (unsigned int c=0; c<GetChannelCount(); c++){
694  ImageDataArray[j][i*GetChannelCount()+c]=_ucBorderColor;
695  ImageDataArray[j][(GetWidth()-1-i)*GetChannelCount()+c]=_ucBorderColor;
696  }
697  }
698  }
699  for (int i = 0; i < HistCount_; i++)
700  DrawHistLog_(i);
701  return 0;
702 }
703 
704 double HistogramImage::GetBin(unsigned int bin,unsigned int hist)
705 {
706  if (bin < BinCount_ && hist < HistCount_) return Hist_[hist][bin];
707  else return -1;
708 }
709 
710 int HistogramImage::SetBin(unsigned int bin,double value, unsigned int hist)
711 {
712  if (bin < BinCount_ && hist < HistCount_) {
713  Hist_[hist][bin] = value;
714  MaxHistEntry_[hist] =0.0;
715 
716  for (unsigned int i=0; i<BinCount_; i++)
717  if (MaxHistEntry_[hist] < Hist_[hist][i])
718  MaxHistEntry_[hist] = Hist_[hist][i];
719  CalcAverage_(hist);
720  return 0;
721  }
722  else return -1;
723 
724 }
725 
726 void HistogramImage::Dump(ostream& os)
727 {
728  double *s=new double[HistCount_];
729  memset((void *)s, 0, sizeof(double)*HistCount_);
730  for (int b=0; b<(int)BinCount_; b++){
731  os << setw(4) << b <<": ";
732  for (int h=0; h<(int)HistCount_; h++){
733  os << setw(8) << Hist_[h][b];
734  s[h]+=Hist_[h][b];
735  }
736  os << endl;
737  }
738  os << " sum: ";
739  for (int h=0; h<(int)HistCount_; h++){
740  os << setw(8) << s[h];
741  }
742  os << endl;
743  os << " avg: ";
744  for (int h=0; h<(int)HistCount_; h++){
745  os << setw(8) << Average_[h];
746  }
747  os << endl;
748  delete[] s;
749 }
750 
751 bool HistogramImage::IsEmpty()
752 {
753  bool result=true;
754  for (int h=0; h<(int)HistCount_; h++){
755  result = result && (MaxHistEntry_[h]==0);
756  }
757  return result;
758 }
759 
760 int HistogramImage::WriteASCII(const std::string& filename)
761 {
762  // first write data file
763  ofstream of(filename.c_str());
764  if (!of){
765  BIASERR("error opening "<<filename);
766  return -1;
767  }
768 
769  WriteASCII(of);
770 
771  if (!of){
772  BIASERR("error writing "<<filename);
773  return -2;
774  }
775  of.close();
776 
777  return 0;
778 }
779 
780 void HistogramImage::WriteASCII(ostream& os)
781 {
782  os << "# "<<HistCount_<<" histogram(s) with "<<BinCount_<<" bins"<<endl;
783  os << "# bin - number of the bin\n";
784  os << "# binb - binborders: [binb, binb+1)\n";
785  os << "# binv - number of values contained in bin\n";
786  os << "#"<<setw(7)<<"bin";
787  double *bs=new double[HistCount_];
788  for (int h=0; h<(int)HistCount_; h++){
789  bs[h]=(MaxBinVal_[h]-MinBinVal_[h])/(double)BinCount_;
790  os <<setw(15)<<"binb"<<setw(12)<<"binv";
791  }
792  os << endl;
793  for (int b=0; b<(int)BinCount_; b++){
794  os << setw(8) << b;
795  for (int h=0; h<(int)HistCount_; h++){
796  os <<setw(15) << MinBinVal_[h]+b*bs[h] << setw(12) << Hist_[h][b];
797  }
798  os << endl;
799  }
800  delete[] bs;
801 }
802 
803 void HistogramImage::CooTransf(double datacoo[2], double imcoo[2], unsigned hist)
804 {
805  double d[2];
806  double maxy=(ScaleYToMaxEntry_)?(MaxHistEntry_[hist]):(NumData_[hist]);
807 
808  d[0]=(datacoo[0]<MinBinVal_[hist])?(MinBinVal_[hist]):
809  ((datacoo[0]>MaxBinVal_[hist])?(MaxBinVal_[hist]):(datacoo[0]));
810  d[1]=(datacoo[1]<0.0)?(0.0):
811  ((datacoo[1]>maxy)?(maxy):(datacoo[1]));
812 
813  imcoo[0]=Factor_ *
814  ((double)_uiBorder+(d[0]-MinBinVal_[hist])/BinSize_[hist]);
815  imcoo[1]=Factor_ * ((double)_uiBorder+double((int)HistSize_-1)*
816  (1.0-d[1]/maxy));
817 }
818 
819 void HistogramImage::CooTransf(double datacoo[2], unsigned imcoo[2], unsigned hist)
820 {
821  double d[2];
822  CooTransf(datacoo, d, hist);
823  imcoo[0]=(unsigned)rint(d[0]);
824  imcoo[1]=(unsigned)rint(d[1]);
825 }
826 
827 /////////////////////////////////////////////////////////////////////////
828 /// Histogram2D
829 /////////////////////////////////////////////////////////////////////////
830 
831 Histogram2D::Histogram2D(unsigned short int zoomfactor)
832  : Image<unsigned char>()
833 {
835  InterleavedDataOrder_ = true;
836  Factor_=zoomfactor;
838  Hist_=NULL;
840  XBinSize_=YBinSize_=0.0;
841  _uiBorder=2;
842  _ucBorderColor=128;
843 }
844 
846 {
847  _ReleaseHist();
848 }
849 
851 {
852  BIASERR("Histogram2D::SetColorModel() not valid for Histogram");
853 }
854 
855 void Histogram2D::SetFactor(unsigned short Factor)
856 {
857  Factor_ = Factor;
859 }
860 
862 {
863  if (Hist_!=NULL){
864  delete[] Hist_[0];
865  delete[] Hist_;
866  }
868  Hist_=NULL;
870  XBinSize_=YBinSize_=0.0;
871  Release();
872 }
873 
874 void Histogram2D::InitHist(unsigned xbincount, unsigned ybincount)
875 {
876  if (Hist_!=NULL){
877  _ReleaseHist();
878  }
879  XBinCount_=ybincount;
880  YBinCount_=xbincount;
881  Hist_=new double*[YBinCount_];
882  Hist_[0]=new double[XBinCount_*YBinCount_];
883  for (unsigned i=1; i<YBinCount_; i++)
884  Hist_[i]=Hist_[i-1]+XBinCount_;
885  // scale image with Factor_
886  Init((XBinCount_ + 2 * _uiBorder) * Factor_ ,
887  (YBinCount_ + 2 * _uiBorder) * Factor_ , 3);
888  // white background
890 }
891 
892 template <class DataType>
893 void Histogram2D::AddHist(const vector<DataType>& xdata,const vector<DataType>& ydata)
894 {
895  DataType maxx=xdata.front(), minx=xdata.front(), maxy=ydata.front(),
896  miny=ydata.front();
897  typename vector<DataType>::const_iterator itx, ity;
898  int xbin, ybin;
899 
900  for (itx=xdata.begin(); itx!=xdata.end(); itx++){
901  if (*itx>maxx) maxx=*itx;
902  if (*itx<minx) minx=*itx;
903  }
904  for (ity=ydata.begin(); ity!=ydata.end(); ity++){
905  if (*ity>maxy) maxy=*ity;
906  if (*ity<miny) miny=*ity;
907  }
908  XMinBinVal_=(double)minx;
909  XMaxBinVal_=(double)maxx;
910  YMinBinVal_=(double)miny;
911  YMaxBinVal_=(double)maxy;
912 
915 #ifdef BIAS_DEBUG
916  if (xdata.size()!=ydata.size()){
917  BIASERR("data vectors have different size "<<xdata.size()<<" "
918  <<ydata.size());
919  }
920 #endif
921  for (itx=xdata.begin(), ity=ydata.begin(); itx!=xdata.end(); itx++, ity++){
922  if (*itx==maxx){
923  xbin=(int)XBinCount_-1;
924  } else {
925  xbin=(int)floor(double((*itx)-minx)/XBinSize_);
926  }
927  if (*ity==maxy){
928  ybin=YBinCount_-1;
929  } else {
930  ybin=(int)floor(double((*ity)-miny)/YBinSize_);
931  }
932 #ifdef BIAS_DEBUG
933  if (xbin<0 || ybin<0)
934  BIASERR("invalid index "<<xbin<<" "<<ybin<<" "<<XBinCount_
935  <<" "<<YBinCount_<<" "<<*itx<<" "<<*ity);
936  if (xbin>=(int)XBinCount_ || ybin>=(int)YBinCount_ )
937  BIASERR("invalid index "<<xbin<<" "<<ybin<<" "<<*itx<<" "<<minx<<" "
938  <<maxx<<" "<<XBinSize_<<" "<<XBinCount_<<" "<<*ity<<" "<<miny
939  <<" "<<maxy<<" "<<YBinSize_<<" "<<YBinCount_);
940 #endif
941  Hist_[ybin][xbin]++;
942  if (Hist_[ybin][xbin]>MaxHistEntry_) MaxHistEntry_=Hist_[ybin][xbin];
943  }
944  /*
945  cerr << "MaxHistEntry_="<<MaxHistEntry_<<endl;
946  double av=0.0;
947  for (unsigned y=0; y<YBinCount_; y++){
948  for (unsigned x=0; x<XBinCount_; x++){
949  av+=Hist_[y][x];
950  }
951  }
952  cerr << "sum="<<av<<endl;
953  cerr << "Average="<<av/double(YBinCount_*XBinCount_)<<endl;
954  */
955 }
956 
957 
959 {
960  BIASASSERT(Hist_!=NULL);
961  memset((void *)Hist_[0], 0, sizeof(double)*XBinCount_*YBinCount_);
962 }
963 
965 {
966  BIASASSERT(Hist_!=NULL);
967  unsigned char **ida=GetImageDataArray(), r, g, b=0;
968  unsigned mx, my, a, f3=3*Factor_;
969 
970  // draw border
971  for (unsigned int i=0; i< Factor_ * _uiBorder; i++){
972  memset((void *)(ida[i]), _ucBorderColor, GetWidthStep() *
973  sizeof(unsigned char));
974  memset((void *)(ida[GetHeight()-1-i]), _ucBorderColor,
975  GetWidthStep() * sizeof(unsigned char) );
976  for (unsigned int j=Factor_ * _uiBorder; j<GetHeight()-Factor_ * _uiBorder;
977  j++){
978  for (unsigned int c=0; c<GetChannelCount(); c++){
979  ida[j][i*GetChannelCount()+c]=_ucBorderColor;
980  ida[j][(GetWidth()-1-i)*GetChannelCount()+c]=_ucBorderColor;
981  }
982  }
983  }
984 
985  // draw histogram
986  for (unsigned y=0; y<YBinCount_; y++){
987  my=(_uiBorder+y)*Factor_;
988  for (unsigned x=0; x<XBinCount_; x++){
989  mx=(_uiBorder+x)*3*Factor_;
990  if (Hist_[y][x]==0.0){
991  r=g=0;
992  } else {
993  a=(unsigned)rint(Hist_[y][x]/MaxHistEntry_*255.0);
994  if (Hist_[y][x]>MaxHistEntry_) {
995  a=255;
996  BIASERR("error in drawing depth");
997  } // from green over yellow to red
998  r=(a>=128)?255:(a*2);
999  g=(a>=128)?((255-a)*2):255;
1000  }
1001 // if (r==255 && g==0)
1002 // cerr <<setw(4)<<x<<setw(4)<<y<<setw(10)<<Hist_[y][x]<<setw(6)<<a<<setw(6)<<(int)r<<setw(6)<<(int)g<<endl;
1003  for (int ro=0; ro<Factor_; ro++){
1004  for (unsigned c=0; c<f3; c+=3){
1005  ida[my+ro][mx+c]=r;
1006  ida[my+ro][mx+c+1]=g;
1007  ida[my+ro][mx+c+2]=b;
1008  }
1009  }
1010  }
1011  }
1012 }
1013 
1015 {
1016  BIASASSERT(Hist_!=NULL);
1017  unsigned char **ida=GetImageDataArray(), r, g, b=0;
1018  unsigned mx, my, a, f3=3*Factor_;
1019 
1020  // draw border
1021  for (unsigned int i=0; i< Factor_ * _uiBorder; i++){
1022  memset((void *)(ida[i]), _ucBorderColor, GetWidthStep() *
1023  sizeof(unsigned char));
1024  memset((void *)(ida[GetHeight()-1-i]), _ucBorderColor,
1025  GetWidthStep() * sizeof(unsigned char) );
1026  for (unsigned int j=Factor_ * _uiBorder; j<GetHeight()-Factor_ * _uiBorder;
1027  j++){
1028  for (unsigned int c=0; c<GetChannelCount(); c++){
1029  ida[j][i*GetChannelCount()+c]=_ucBorderColor;
1030  ida[j][(GetWidth()-1-i)*GetChannelCount()+c]=_ucBorderColor;
1031  }
1032  }
1033  }
1034 
1035  // draw histogram
1036  for (unsigned y=0; y<YBinCount_; y++){
1037  my=(_uiBorder+YBinCount_-1-y)*Factor_;
1038  for (unsigned x=0; x<XBinCount_; x++){
1039  mx=(_uiBorder+x)*3*Factor_;
1040  if (Hist_[y][x]==0.0){
1041  r=g=0;
1042  } else {
1043  a=(unsigned)rint(log10((Hist_[y][x]/MaxHistEntry_)*9.0+1.0)*255.0);
1044  if (Hist_[y][x]>MaxHistEntry_) {
1045  a=255;
1046  BIASERR("error in drawing depth");
1047  } // from green over yellow to red
1048  r=(a>=128)?255:(a*2);
1049  g=(a>=128)?((255-a)*2):255;
1050  }
1051 // if (r==255 && g==0)
1052 // cerr <<setw(4)<<x<<setw(4)<<y<<setw(10)<<Hist_[y][x]<<setw(6)<<a<<setw(6)<<(int)r<<setw(6)<<(int)g<<endl;
1053  for (int ro=0; ro<Factor_; ro++){
1054  for (unsigned c=0; c<f3; c+=3){
1055  ida[my+ro][mx+c]=r;
1056  ida[my+ro][mx+c+1]=g;
1057  ida[my+ro][mx+c+2]=b;
1058  }
1059  }
1060  }
1061  }
1062 }
1063 
1064 void Histogram2D::Dump(std::ostream& os)
1065 {
1066  os <<"# 2D Histogram with "<<XBinCount_<<" x "<<YBinCount_<<" bins\n"
1067  <<"# x bins from "<<XMinBinVal_<<" to "<<XMaxBinVal_<<endl
1068  <<"# y bins from "<<YMinBinVal_<<" to "<<YMaxBinVal_<<endl
1069  <<"# x, y - coo of bin\n"
1070  <<"# xval, yval - the value of the entries of the bin\n"
1071  <<"# count - number of entries in bin\n"
1072  <<"#\n"
1073  <<"# "<<setw(4)<<"y"<<setw(15)<<"yval"<<setw(6)<<"x"<<setw(15)<<"xval"
1074  <<setw(15)<<"val"<<setw(6)<<"x"<<setw(15)<<"xval"<<setw(15)<<"val"
1075  <<setw(6)<<"x"<<setw(15)<<"xval"<<setw(15)<<"count"
1076  <<setw(6)<<"...\n";
1077  for (unsigned y=0; y<YBinCount_; y++){
1078  os << setw(6) << y << setw(15) << YMinBinVal_+y*YBinSize_;
1079  for (unsigned x=0; x<XBinCount_; x++){
1080  os << setw(6) << x << setw(15) << XMinBinVal_+x*XBinSize_
1081  << setw(15) << Hist_[y][x];
1082  }
1083  os << endl;
1084  }
1085 }
1086 
1087 void Histogram2D::WriteASCII(std::ostream& os)
1088 {
1089  os <<"# 2D Histogram with "<<XBinCount_<<" x "<<YBinCount_<<" bins\n"
1090  <<"# x bins from "<<XMinBinVal_<<" to "<<XMaxBinVal_<<endl
1091  <<"# y bins from "<<YMinBinVal_<<" to "<<YMaxBinVal_<<endl
1092  <<"# x, y - coo of bin\n"
1093  <<"# xval, yval - the value of the entries of the bin\n"
1094  <<"# count - number of entries in bin\n"
1095  <<"#\n"
1096  <<"# "<<setw(6)<<"y"<<setw(15)<<"yval"<<setw(8)<<"x"<<setw(15)<<"xval"
1097  <<setw(15)<<"count\n";
1098  for (unsigned y=0; y<YBinCount_; y++){
1099  for (unsigned x=0; x<XBinCount_; x++){
1100  os << setw(8) << y << setw(15) << YMinBinVal_+y*YBinSize_
1101  << setw(8) << x << setw(15) << XMinBinVal_+x*XBinSize_
1102  << setw(15) << Hist_[y][x] << endl;
1103  }
1104  os << endl << endl << endl;
1105  }
1106 }
1107 
1108 void Histogram2D::CooTransf(double datacoo[2], double imcoo[2])
1109 {
1110  double d[2];
1111  d[0]=(datacoo[0]<XMinBinVal_)?(XMinBinVal_):
1112  ((datacoo[0]>XMaxBinVal_)?(XMaxBinVal_):(datacoo[0]));
1113  d[1]=(datacoo[1]<YMinBinVal_)?(YMinBinVal_):
1114  ((datacoo[1]>YMaxBinVal_)?(YMaxBinVal_):(datacoo[1]));
1115 
1116  imcoo[0]=Factor_ * (_uiBorder + (d[0]-XMinBinVal_)/XBinSize_);
1117  imcoo[1]=Factor_ * (_uiBorder + (d[1]-YMinBinVal_)/YBinSize_);
1118 
1119 }
1120 
1121 void Histogram2D::CooTransf(double datacoo[2], unsigned imcoo[2])
1122 {
1123  double d[2];
1124  CooTransf(datacoo, d);
1125  imcoo[0]=(unsigned)rint(d[0]);
1126  imcoo[1]=(unsigned)rint(d[1]);
1127 }
1128 
1129 
1130 
1131 ///
1132 /// must be at end of file cmenk, jw
1133 ///
1134 
1135 
1136 #define INST_ADDHIST(DataType)\
1137 template int BIASImage_EXPORT HistogramImage::AddHist<DataType>(const std::vector<DataType>& data, DataType min, DataType max, unsigned int hist ); \
1138 template int BIASImage_EXPORT HistogramImage::AddHist<DataType>(const std::vector<DataType>& data, unsigned int hist); \
1139 template void BIASImage_EXPORT Histogram2D::AddHist(const std::vector<DataType>& xdata,const std::vector<DataType>& ydata);
1140 
1141 INST_ADDHIST(unsigned char)
1142 INST_ADDHIST(float)
1143 INST_ADDHIST(double)
1144 INST_ADDHIST(int)
1145 INST_ADDHIST(unsigned int)
1146 
1147 
1148 
1149 #define INST_ADDHIST_IMG(DataType)\
1150 template int BIASImage_EXPORT HistogramImage::AddHist<DataType>(const Image<DataType> &src, unsigned hist); \
1151 
1152 #ifdef BUILD_IMAGE_UCHAR
1153 INST_ADDHIST_IMG(float)
1154 #endif
1155 
1156 // no explicit instance as there is an exported specialization (cmenk, jw)
1157 //INST_ADDHIST_IMG(unsigned char);
1158 
1159 #ifdef BUILD_IMAGE_INT
1160 INST_ADDHIST_IMG(int)
1161 #endif
1162 #ifdef BUILD_IMAGE_CHAR
1163 INST_ADDHIST_IMG(char)
1164 #endif
1165 #ifdef BUILD_IMAGE_SHORT
1166 INST_ADDHIST_IMG(short)
1167 #endif
1168 #ifdef BUILD_IMAGE_USHORT
1169 INST_ADDHIST_IMG(unsigned short)
1170 #endif
1171 #ifdef BUILD_IMAGE_UINT
1172 INST_ADDHIST_IMG(unsigned int)
1173 #endif
1174 #ifdef BUILD_IMAGE_DOUBLE
1175 INST_ADDHIST_IMG(double)
1176 #endif
1177 
1178 
1179 } // end namespace
void Release()
reimplemented from ImageBase
class for handling different region of interest (ROI) representations...
Definition: ROI.hh:118
void InitHist(unsigned xbincount=256, unsigned ybincount=256)
bool InterleavedDataOrder_
planar or interleaved: planar means we have several image planes, e.g.
Definition: ImageBase.hh:1070
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
Definition: ImageBase.hh:245
unsigned int _uiBorder
unsigned int GetWidthStep() const
returns the number of bytes per line
Definition: ImageBase.hh:400
void Dump(std::ostream &os=std::cout)
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 ...
Definition: Image.cpp:802
unsigned int GetWidth() const
Definition: ImageBase.hh:312
void SetColorModel()
dummy function to avoid swapping color model in this class
unsigned short int Factor_
ROI * GetROI()
Returns a pointer to the roi object.
Definition: ImageBase.hh:615
bool IsInROI(const double &x, const double &y) const
ROI check if pixel position is inside the ROI.
Definition: ROI.hh:463
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
color values, 3 channels, order: red,green,blue
Definition: ImageBase.hh:131
unsigned int GetHeight() const
Definition: ImageBase.hh:319
void FillImageWithConstValue(unsigned charValue)
fill grey images
The image template class for specific storage types.
Definition: Image.hh:78
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
void CooTransf(double datacoo[2], double imcoo[2])
transforms data coordinates to image coordinates automatic clipping of imcoo is performed ...
void WriteASCII(std::ostream &os=std::cout)
writes ascii data to stream, can be used later e.g. with gnuplot
unsigned char _ucBorderColor
drawing simple entities into the image like rectangles or lines As all functions are static they have...
Definition: ImageDraw.hh:72
void AddHist(const std::vector< DataType > &xdata, const std::vector< DataType > &ydata)
unsigned long int GetPixelCount() const
returns number of pixels in image
Definition: ImageBase.hh:422
void SetFactor(unsigned short Factor)
sets the zoomfactor
enum EColorModel ColorModel_
the color model of the pixels
Definition: ImageBase.hh:1054
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase
Definition: Image.hh:153