void HistogramWidget::initializeHistogram(vtkImageData* img){
- if(histogram ==NULL){
+ if(histogram ==NULL)
+ {
histogram= new pHistogram(img);
}
//draw
xValues=(double*)malloc(NUM_POINTS*sizeof(double));
yValues=(double*)malloc(NUM_POINTS*sizeof(double));
- unsigned short* histogramPointer=(unsigned short*)histogramImageData->GetScalarPointer(0,0,0);
-
- for(int i=0; i< histogramSize; i++)
+ double* histogramPointer=(double*)histogramImageData->GetScalarPointer(0,0,0);
+ int i;
+ for(i=0; i< histogramSize; i++)
{
xValues[i]=i;
- yValues[i]=log( (double) histogramPointer[i]);
- }
+ if (histogramPointer[i]==0)
+ {
+ yValues[i]=0;
+ } else {
+ yValues[i]=log(histogramPointer[i])*10;
+ } // histogramPointer
+ } // for i
pGraphicalFunction* histogramFunction=plotter->getFunctionForVectors(xValues,histogramSize,yValues,histogramSize);
*/
void HistogramWidget::drawTransferenceFunction()
{
-
double xValues[5],yValues[5];
//xValues
int maxValueGrey=histogram->getMaximumLevelOfGrey();
yValues[4]=0;
pGraphicalFunction * tf = plotter ->getFunctionForVectors( xValues, 5, yValues, 5 );
- printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf);
+ printf("EED %p HistogramWidget::drawTransferenceFunction %p\n", this , tf);
// Including and drawing the created function in the plotter
if (tf)
{
tf->SetShowPoints(true);
idTransferenceFunction=plotter->addFunction( tf );
if(type==1)
+ {
plotter->addFunctionToMove(tf);
+ }
wxPen mypen(*wxBLACK,0.5, wxSOLID );
mypen.SetWidth(2);
tf->SetPen( mypen );
- }
+ } // if tf
}
/*
GetClientSize(&scrX,&scrY);
plotter->SetSize(scrX,scrY);
pGraphicalFunction* actual=plotter->getFunction(idTransferenceFunction);
- if(actual!=NULL){
+ if(actual!=NULL)
+ {
actual->setScreens(scrX,scrY);
actual->setScales();
}
void HistogramWidget::getTransferenceFunctionPoint(int index,int& x,int& y)
{
pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
- if(tf)
+ if(tf!=NULL)
{
- wxNode* pnode=tf->GetPointAt(index);
- pFunctionPoint* point=(pFunctionPoint*)pnode->GetData();
- x=point->getRealX();
- y=point->getRealY();
+ wxNode* pnode = tf->GetPointAt(index);
+ pFunctionPoint* point = (pFunctionPoint*)pnode->GetData();
+ x = point->getRealX();
+ y = point->getRealY();
}
}
/*
/*
get a color int the bqr color
*/
- void HistogramWidget:: getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue)
+ void HistogramWidget::getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue)
{
- double tmp=x;
+ double tmp = x;
plotter->getBarColorDataAt(index,tmp,red,green,blue);
- x=(int)tmp;
+ x = (int)tmp;
}
/*
Returns the maximum value ot the histogram that is show to the user
*/
float HistogramWidget::getMaxShowedPorcentage()
{
- float porcentageMaxX=plotter->getMaxShowedPorcentage();
- pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
- int min=histogramFunction->getMinX();
- float x=porcentageMaxX*(histogramFunction->getMaxX()-min);
+ float porcentageMaxX = plotter->getMaxShowedPorcentage();
+ pGraphicalFunction* histogramFunction = plotter->getFunction(idHistogram);
+ int min = histogramFunction->getMinX();
+ float x = porcentageMaxX*(histogramFunction->getMaxX()-min);
return min+ x;
}
/*
*/
float HistogramWidget::getMinShowedPorcentage()
{
- float porcentageMinX=plotter->getMinShowedPorcentage();
- pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
- int min=histogramFunction->getMinX();
- float x=porcentageMinX*(histogramFunction->getMaxX()-min);
+ float porcentageMinX = plotter->getMinShowedPorcentage();
+ pGraphicalFunction* histogramFunction = plotter->getFunction(idHistogram);
+ int min = histogramFunction->getMinX();
+ float x = porcentageMinX*(histogramFunction->getMaxX()-min);
return min+ x;
}
/*
*/
float HistogramWidget::getActualShowedPorcentage()
{
- float porcentageActualX=plotter->getMinShowedPorcentage();
- pGraphicalFunction* histogramFunction=plotter->getFunction(idHistogram);
- int min=histogramFunction->getMinX();
- float x=porcentageActualX*(histogramFunction->getMaxX()-min);
- return min+ x;
+ float porcentageActualX = plotter->getMinShowedPorcentage();
+ pGraphicalFunction* histogramFunction = plotter->getFunction(idHistogram);
+ int min = histogramFunction->getMinX();
+ float x = porcentageActualX*(histogramFunction->getMaxX()-min);
+ return min + x;
}
//---------------------------------------
// setting data in transferences function
bool result=false;
pGraphicalFunction* tf=plotter->getFunction(idTransferenceFunction);
//printf("EED %p HistogramWidget::addPointToTransferenceFunction tp%p x%f y%f %d\n",this, tf, x ,y, idTransferenceFunction);
- if (tf!=NULL) { result=tf->AddPoint(x,y); }
+ if (tf!=NULL)
+ {
+ result=tf->AddPoint(x,y);
+ } // if tf
return result;
}
void HistogramWidget::setTransferenceFunctionHasPoints(bool hasPoints)
{
- transferenceFunctionHasPoints=hasPoints;
+ transferenceFunctionHasPoints = hasPoints;
}
void HistogramWidget::setTransferenceFunctionHasColor(bool hasColorPoints)
{
- transferenceFunctionHasPoints=hasColorPoints;
+ transferenceFunctionHasPoints = hasColorPoints;
}
+
int HistogramWidget::getHistogramSize()
{
return histogramSize;
}
+
void HistogramWidget::setType(int type)
{
- this->type=type;
+ this->type = type;
}
/**
** Returns two vectors, the grey level of the point and its value, the value is between [0,1]
**/
- void HistogramWidget::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value){
+ void HistogramWidget::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value)
+ {
plotter->GetValuesPointsFunction(greylevel,value,histogramSize);
}