#include <pHistogram.h>
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 |
Definition at line 41 of file pHistogram.h.
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 }
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 }
pHistogram::~pHistogram | ( | ) |
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 }
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 }
vtkImageData * pHistogram::getHistogram | ( | ) |
Definition at line 204 of file pHistogram.cxx.
References points.
Referenced by HistogramWidget::drawHistogram(), and Histogram::drawHistogram().
00205 { 00206 return points; 00207 }
int pHistogram::getHistogramPoint | ( | int | gValue | ) |
Definition at line 259 of file pHistogram.cxx.
References points.
Referenced by HistogramWidget::getHistogramPoint(), and Histogram::getHistogramPoint().
00260 { 00261 //double p=((float)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey); // JPRx 00262 //double k=p*size; 00263 00264 unsigned short* dataHistogramPointer=NULL; 00265 dataHistogramPointer=(unsigned short*)points->GetScalarPointer(0,0,0); 00266 00267 return dataHistogramPointer[gValue]; 00268 }
int pHistogram::getImageSize | ( | ) |
Definition at line 230 of file pHistogram.cxx.
References sizeImage.
00231 { 00232 return sizeImage; 00233 }
int pHistogram::getIndex | ( | int | gValue | ) |
Definition at line 214 of file pHistogram.cxx.
References maxLevelOfGrey, minLevelOfGrey, and size.
Referenced by setPoints().
00215 { 00216 double p=((float)gValue-minLevelOfGrey)/(maxLevelOfGrey-minLevelOfGrey); 00217 double k=p*(size-1); 00218 return (int)k; 00219 }
int pHistogram::getMaximumLevelOfGrey | ( | ) |
Definition at line 244 of file pHistogram.cxx.
References maxLevelOfGrey.
Referenced by HistogramWidget::drawTransferenceFunction().
00245 { 00246 return maxLevelOfGrey; 00247 }
int pHistogram::getMinimumLevelOfGrey | ( | ) |
Definition at line 251 of file pHistogram.cxx.
References minLevelOfGrey.
00252 { 00253 return minLevelOfGrey; 00254 }
std::vector<int> pHistogram::getPoints | ( | ) |
int pHistogram::getSize | ( | ) |
Definition at line 237 of file pHistogram.cxx.
References size.
Referenced by HistogramWidget::drawHistogram(), and Histogram::drawHistogram().
00238 { 00239 return size; 00240 }
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 }
void pHistogram::setImagePath | ( | std::string | filePath | ) |
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 /* 00153 Image Size 00154 */ 00155 int ext[6]; 00156 imageData->GetExtent(ext); 00157 int sx,sy,sz; 00158 sx=ext[1]+1; 00159 sy=ext[3]+1; 00160 sz=ext[5]+1; 00161 00162 sizeImage=sx*sy*sz; 00163 00164 int i; 00165 /* 00166 getting ready the histogram 00167 */ 00168 for(i=0;i<size;i++) 00169 { 00170 dataHistogramPointer[i]=0; 00171 } 00172 00173 /* 00174 Constructing the Histogram 00175 */ 00176 //int k=size/(maxLevelOfGrey-minLevelOfGrey); 00177 int j=0; 00178 for(i=0;i<sizeImage;i++) 00179 { 00180 /* 00181 hashing the histogram 00182 */ 00183 //double p=((float)*dataImagePointer-minLevelOfGrey); 00184 //j=p*k; 00185 00186 j=getIndex(*dataImagePointer); 00187 dataHistogramPointer[j]++; 00188 dataImagePointer++; 00189 } 00190 /* 00191 BORRAME 00192 */ 00193 /* 00194 k=0; 00195 for(i=0;i<size;i++) 00196 { 00197 k=dataHistogramPointer[i]; 00198 } 00199 */ 00200 }
void pHistogram::setSize | ( | int | nSize | ) |
int pHistogram::maxLevelOfGrey [private] |
Definition at line 141 of file pHistogram.h.
Referenced by getIndex(), getMaximumLevelOfGrey(), and setPoints().
int pHistogram::minLevelOfGrey [private] |
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] |
Definition at line 129 of file pHistogram.h.
Referenced by buildHistogram(), getHistogram(), getHistogramPoint(), initializePoints(), pHistogram(), setPoints(), and ~pHistogram().
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().