// vtkImageData *m_image = vtkImageData::New();
// m_image = bbGetInputImage();
- double grayLevel = -9999;
- std::vector<double> coord = bbGetInputCoordinate();
-
+ double grayLevel = -9999;
+ std::vector<double> coord = bbGetInputCoordinate();
+ double px,py,pz;
if (bbGetInputImage()!=NULL)
{
- grayLevel = bbGetInputImage()->GetScalarComponentAsDouble(coord[0],coord[1],coord[2],0);
- }
+ double spc[3];
+ bbGetInputImage()->GetSpacing(spc);
+ if (coord.size()>=2)
+ {
+ if (bbGetInputWithSpacing()==true)
+ {
+ px = round(coord[0])/spc[0];
+ py = round(coord[1])/spc[1];
+ pz = round(coord[2])/spc[2];
+ } else {
+ px = round(coord[0]);
+ py = round(coord[1]);
+ pz = round(coord[2]);
+ }// if
+ grayLevel = bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0);
+ } // coord
+ std::vector<double> lstGL;
+ std::vector<double> lstX = bbGetInputLstPointsX();
+ std::vector<double> lstY = bbGetInputLstPointsY();
+ std::vector<double> lstZ = bbGetInputLstPointsZ();
+ if ( (lstX.size()==lstY.size()) && (lstY.size()==lstZ.size()) )
+ {
+ long int i,size=lstX.size();
+ for (i=0;i<size;i++)
+ {
+ if (bbGetInputWithSpacing()==true)
+ {
+ px = round(lstX[i])/spc[0];
+ py = round(lstY[i])/spc[1];
+ pz = round(lstZ[i])/spc[2];
+ } else {
+ px = round(lstX[i]);
+ py = round(lstY[i]);
+ pz = round(lstZ[i]);
+ }// if
+ lstGL.push_back( bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0) );
+ }// for
+ bbSetOutputLstGrayLevel(lstGL);
+ } // if size of Lst
+ } // InputImage
bbSetOutputGrayLevel(grayLevel);
-
}
+
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
void GrayLevel::bbUserSetDefaultValues()
{
-
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
bbSetInputImage(NULL);
-
+ bbSetInputWithSpacing(false);
}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)