pHistogram Class Reference

#include <pHistogram.h>

List of all members.

Public Member Functions

 pHistogram (std::string filePath)
 pHistogram (vtkImageData *imageData)
 ~pHistogram ()
void setImagePath (std::string filePath)
std::vector< int > getPoints ()
void buildHistogram ()
void buildHistogram (vtkImageData *imageData)
void initializePoints (int xDimension)
void setPoints (vtkImageData *imageData)
vtkImageData * getHistogram ()
int getIndex (int gValue)
void setSize (int nSize)
int getImageSize ()
int getSize ()
int getMaximumLevelOfGrey ()
int getMinimumLevelOfGrey ()
int getHistogramPoint (int gValue)

Private Attributes

vtkImageData * points
std::string path
int size
int maxLevelOfGrey
int minLevelOfGrey
int sizeImage

Detailed Description

Definition at line 41 of file pHistogram.h.


Constructor & Destructor Documentation

pHistogram::pHistogram ( std::string  filePath  ) 

Definition at line 37 of file pHistogram.cxx.

References buildHistogram(), path, points, size, and sizeImage.

00038 {
00039         path=filePath;
00040         points= vtkImageData::New();
00041         size=100;
00042         sizeImage=0;
00043         buildHistogram();
00044 }

Here is the call graph for this function:

pHistogram::pHistogram ( vtkImageData *  imageData  ) 

Definition at line 46 of file pHistogram.cxx.

References buildHistogram(), points, size, and sizeImage.

00047 {
00048         points= vtkImageData::New();
00049         size=100;
00050         sizeImage=0;
00051         //cast
00052         /*
00053         vtkImageCast* cast= vtkImageCast::New();
00054         cast->SetInput(imageData);
00055         cast->SetOutputScalarTypeToInt();
00056         cast->Update();
00057         */
00058         //build the histogram
00059         buildHistogram(imageData);
00060 }

Here is the call graph for this function:

pHistogram::~pHistogram (  ) 

Definition at line 62 of file pHistogram.cxx.

References points.

00063 {
00064         if(points!=NULL)points->Delete();
00065 }


Member Function Documentation

void pHistogram::buildHistogram ( vtkImageData *  imageData  ) 

Definition at line 107 of file pHistogram.cxx.

References initializePoints(), setPoints(), and size.

00108 {
00109         initializePoints(size);
00110         setPoints(imageData);   
00111 }

Here is the call graph for this function:

void pHistogram::buildHistogram (  ) 

Definition at line 75 of file pHistogram.cxx.

References initializePoints(), path, points, setPoints(), and size.

Referenced by pHistogram().

00076 {
00077         /*
00078                 reader: is the reader of the image
00079                 histogramVector:Is the image data of the original image
00080                 imageData: vtkImageData of the image that we are reading
00081                 range :it has the (min/max) range of the levels of grey
00082         */
00083         points= vtkImageData::New();
00084         vtkMetaImageReader *reader = vtkMetaImageReader::New();
00085         vtkImageData* imageData=NULL;
00086         double range[2];
00087         
00088         //reading
00089         reader->SetFileName(path.c_str());
00090         reader->Update();
00091 
00092         
00093         // getting the data 
00094         imageData=reader->GetOutput();
00095         imageData->GetScalarRange(range);
00096         initializePoints(size);
00097         setPoints(imageData);
00098         
00099 }

Here is the call graph for this function:

Here is the caller graph for this function:

vtkImageData * pHistogram::getHistogram (  ) 

Definition at line 206 of file pHistogram.cxx.

References points.

Referenced by HistogramWidget::drawHistogram(), and Histogram::drawHistogram().

00207 {
00208         return points;
00209 }

Here is the caller graph for this function:

int pHistogram::getHistogramPoint ( int  gValue  ) 

Definition at line 263 of file pHistogram.cxx.

References points.

Referenced by HistogramWidget::getHistogramPoint(), and Histogram::getHistogramPoint().

00264 {
00265         //double p=((float)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey); // JPRx
00266         //double k=p*size;
00267 
00268         unsigned short* dataHistogramPointer=NULL;
00269         dataHistogramPointer=(unsigned short*)points->GetScalarPointer(0,0,0);
00270 
00271         return dataHistogramPointer[gValue];
00272 }

Here is the caller graph for this function:

int pHistogram::getImageSize (  ) 

Definition at line 234 of file pHistogram.cxx.

References sizeImage.

00235 { 
00236         return sizeImage;
00237 }

int pHistogram::getIndex ( int  gValue  ) 

Definition at line 216 of file pHistogram.cxx.

References maxLevelOfGrey, minLevelOfGrey, and size.

Referenced by setPoints().

00217 {
00218 
00219         double p=((double)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey);
00220         double k=p*(size-1);
00221         //std::cout<<"gValue "<<gValue<<" k "<<k<<std::endl;
00222         return (int)k;
00223 }

Here is the caller graph for this function:

int pHistogram::getMaximumLevelOfGrey (  ) 

Definition at line 248 of file pHistogram.cxx.

References maxLevelOfGrey.

Referenced by HistogramWidget::drawTransferenceFunction().

00249 {
00250         return maxLevelOfGrey;
00251 }

Here is the caller graph for this function:

int pHistogram::getMinimumLevelOfGrey (  ) 

Definition at line 255 of file pHistogram.cxx.

References minLevelOfGrey.

00256 {
00257         return minLevelOfGrey;
00258 }

std::vector<int> pHistogram::getPoints (  ) 
int pHistogram::getSize (  ) 

Definition at line 241 of file pHistogram.cxx.

References size.

Referenced by HistogramWidget::drawHistogram(), and Histogram::drawHistogram().

00242 {
00243         return size;
00244 }

Here is the caller graph for this function:

void pHistogram::initializePoints ( int  xDimension  ) 

Definition at line 116 of file pHistogram.cxx.

References points.

Referenced by buildHistogram().

00117 {
00118         //setting image data of the points
00119         points->SetDimensions(xDimension,1,1);
00120         points->SetScalarTypeToUnsignedShort();
00121         points->AllocateScalars();
00122         points->Update();
00123 }

Here is the caller graph for this function:

void pHistogram::setImagePath ( std::string  filePath  ) 

Definition at line 70 of file pHistogram.cxx.

References path.

00071 {
00072         path=filePath;
00073 }

void pHistogram::setPoints ( vtkImageData *  imageData  ) 

Definition at line 128 of file pHistogram.cxx.

References getIndex(), maxLevelOfGrey, minLevelOfGrey, points, size, and sizeImage.

Referenced by buildHistogram().

00129 {
00130         /*
00131                 Pointers
00132         */
00133         unsigned short* dataImagePointer=NULL;
00134         unsigned short* dataHistogramPointer=NULL;
00135 
00136         dataImagePointer=(unsigned short*)imageData->GetScalarPointer(0,0,0);
00137         dataHistogramPointer=(unsigned short*)points->GetScalarPointer(0,0,0);
00138         
00139         /*
00140          Range of greys
00141         */
00142         double range[2];
00143         if(imageData==NULL)
00144                 range[1]=1;
00145         else
00146                 imageData->GetScalarRange(range);
00147         /*
00148          Setting the  minimun and maximum levels of grey
00149         */
00150         maxLevelOfGrey=(int)range[1];
00151         minLevelOfGrey=(int)range[0];
00152         //std::cout<<"maxLevelOfGrey "<<maxLevelOfGrey<<" minLevelOfGrey "<<minLevelOfGrey<<std::endl;
00153         /*
00154          Image Size
00155         */
00156         int ext[6];
00157         imageData->GetExtent(ext);
00158         int sx,sy,sz;
00159         sx=ext[1]+1;
00160         sy=ext[3]+1;
00161         sz=ext[5]+1;
00162 
00163         sizeImage=sx*sy*sz;
00164 
00165         int i;
00166         /*
00167           getting ready the histogram
00168         */
00169         for(i=0;i<size;i++)
00170         {
00171                 dataHistogramPointer[i]=0;
00172         }
00173         
00174         /*
00175         Constructing the Histogram
00176         */
00177         //int k=size/(maxLevelOfGrey-minLevelOfGrey);
00178         int j=0;
00179         for(i=0;i<sizeImage;i++)
00180         {
00181                 /*
00182                  hashing the histogram
00183                 */
00184                 //double p=((float)*dataImagePointer-minLevelOfGrey);
00185                 //j=p*k;
00186                 
00187                 j=getIndex(*dataImagePointer);
00188                 //std::cout<<j<<std::endl;
00189                 dataHistogramPointer[j]++;
00190                 dataImagePointer++;
00191         }
00192         /*
00193         BORRAME
00194         */
00195         /*
00196         k=0;
00197         for(i=0;i<size;i++)
00198         {
00199                 k=dataHistogramPointer[i];
00200         }
00201         */
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pHistogram::setSize ( int  nSize  ) 

Definition at line 227 of file pHistogram.cxx.

References size.

00228 {
00229         size=nSize;
00230 }


Member Data Documentation

Definition at line 141 of file pHistogram.h.

Referenced by getIndex(), getMaximumLevelOfGrey(), and setPoints().

Definition at line 145 of file pHistogram.h.

Referenced by getIndex(), getMinimumLevelOfGrey(), and setPoints().

std::string pHistogram::path [private]

Definition at line 133 of file pHistogram.h.

Referenced by buildHistogram(), pHistogram(), and setImagePath().

vtkImageData* pHistogram::points [private]
int pHistogram::size [private]

Definition at line 137 of file pHistogram.h.

Referenced by buildHistogram(), getIndex(), getSize(), pHistogram(), setPoints(), and setSize().

int pHistogram::sizeImage [private]

Definition at line 149 of file pHistogram.h.

Referenced by getImageSize(), pHistogram(), and setPoints().


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

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1