Exemple #1
0
void ZSparseObject::display(ZPainter &painter, int z, EDisplayStyle option) const
{
  if (m_stackGrid.isEmpty() || z < 0) {
    ZObject3dScan::display(painter, z, option);
  } else {
    UNUSED_PARAMETER(option);
    z -= iround(painter.getZOffset());
    QPen pen(m_color);
    painter.setPen(pen);

    size_t stripeNumber = getStripeNumber();
    for (size_t i = 0; i < stripeNumber; ++i) {
      const ZObject3dStripe &stripe = getStripe(i);
      if (stripe.getZ() == z) {
        int nseg = stripe.getSegmentNumber();
        for (int j = 0; j < nseg; ++j) {
          int x0 = stripe.getSegmentStart(j);
          int x1 = stripe.getSegmentEnd(j);
          int y = stripe.getY();
          for (int x = x0; x <= x1; ++x) {
            int v = getVoxelValue(x, y, z);
            painter.setPen(QColor(v, v, v));
            painter.drawPoint(QPoint(x, y));
          }
        }
      }
    }
  }
}
Exemple #2
0
	Image* Volume::extractSlice(unsigned int index, CoordinateOrder orientation /*= ORDER_XYZ*/) const
	{
		unsigned int orderDependentIndices[3];
		fillOrderDependentIndices(orderDependentIndices, orientation);
		Vec3ui outputResolution;
		outputResolution.z = properties.getVolumeResolution()[orderDependentIndices[0]];
		outputResolution.y = properties.getVolumeResolution()[orderDependentIndices[1]];
		outputResolution.x = properties.getVolumeResolution()[orderDependentIndices[2]];

		auto *result = new Image(outputResolution.xy());

		Vec3ui coords;
		coords[orderDependentIndices[0]] = index;
		for (unsigned int j = 0; j < result->getResolution().y; ++j)
		{
			for (unsigned int i = 0; i < result->getResolution().x; ++i)
			{
				coords[orderDependentIndices[1]] = j;
				coords[orderDependentIndices[2]] = i;
				result->setPixel(i, j, getVoxelValue(coords));
			}
		}

		return result;
	}
Exemple #3
0
 void Volume::scaleVoxelValues(int numenator, int denominator /*= 1*/)
 {
     float scaledValue;
     for( size_t i = 0; i < properties.getVolumeVoxelCount(); ++i )
     {
         scaledValue = getVoxelValue(i) * numenator / denominator;
         setVoxelToValue(i, scaledValue);
     }
 }
Exemple #4
0
int main(int argc,char** argv)
{
  AnalyzeImage imgin,imgout;
  int x,y,z,labelsToChange,i;
  int intstatus;  
  int inlabel,outlabel;
  bool clobber = true;
  bool status;
  div_t divtmp;

  if(argc < 5) {
    cout << "Usage: relabel_analyze inputfile outputfile inlabel1 outlabel1" << endl;
    return(1);
  }
  intstatus = readImage(argv[1],&imgin);
  if(intstatus != 0) {
    cout << "Could not read the file" << argv[1] << endl;
    return(2);
  }
  status = copyImage(&imgin,&imgout);
  divtmp = div(argc - 3,2);
  if(divtmp.rem == 0) {
    labelsToChange = divtmp.quot;
    
  }
  else {
    cout << " wrong number of inputs" << endl;
    return(3);
  }
  for(i = 0;i < labelsToChange;i++) {
    inlabel = atoi(argv[2*i + 3]);
    outlabel = atoi(argv[2*i + 4]);
    cout << "Changing" << inlabel << "->" << outlabel << endl;
    for(x = 0;x < imgin.header.x_dim;x++) {
      for(y = 0;y < imgin.header.y_dim;y++) {
        for(z = 0;z < imgin.header.z_dim;z++) {
          if(fabs(getVoxelValue(&imgin,x,y,z) - inlabel) < 0.0001)
	    putVoxelValue(&imgout,x,y,z,outlabel);
        }
      }
    }
  }
  intstatus = writeImage(argv[2],&imgout,clobber);
  if(intstatus != 0) {
    cout << "Could not write the file" << argv[2] << endl;
    return(3);
  }
  return(0);



}
int main(int argc,char** argv)
{
  AnalyzeImage img,timg;
  int intstatus;
  int i,j,k;
  int xtrans,ytrans,ztrans,xstart,ystart,zstart,xend,yend,zend;
  bool status;

  if( argc < 6) {
    cout << "Usage: translate_analyze inputfile outputfile x_trans y_trans z_trans" << endl;
    cout << "Images are assumed to be transaxial." << endl;
    cout << "Translations are given relative to voxels and not in millimeters" << endl;   
  }
  intstatus = readImage(argv[1],&img);
  if(intstatus != 0) {
    cout << "Could not read the file" << argv[1] << endl;
    return(2);
  }
  xtrans = atoi(argv[3]);
  ytrans = atoi(argv[4]);
  ztrans = atoi(argv[5]);

  if(xtrans < 0) {
    xstart = -xtrans;
    xend = img.header.x_dim;
  }
  else {  
    xstart = 0;
    xend = img.header.x_dim - xtrans;
  }   
  if(ytrans < 0) {
    ystart = -ytrans;
    yend = img.header.y_dim;
  }
  else {  
    ystart = 0;
    yend = img.header.y_dim - ytrans;
  }   
  if(ztrans < 0) {
    zstart = -ztrans;
    zend = img.header.z_dim;
  }
  else {  
    zstart = 0;
    zend = img.header.z_dim - ztrans;
  }   
 
  status = newImage(&timg,&img);
  for(i = xstart;i < xend;i++) {  
    for(j = ystart;j < yend;j++) {
      for(k = zstart;k < zend;k++) {
        putVoxelValue(&timg,i + xtrans ,j + ytrans,k + ztrans,getVoxelValue(&img,i,j,k));
      }
    }
  }
  intstatus = writeImage(argv[2],&timg,true);
  if(intstatus != 0) {
    cout << "Could not write the file" << argv[2] << endl;
    return(3);
  }
  return(0);
}
Exemple #6
0
 float Volume::getVoxelValue(const Vec3i& coords, BorderTreatment borderTreatment) const
 {
     return getVoxelValue(getVoxelIndex(coords, borderTreatment));
 }