[Insight-users] change every voxel value of a 3d image

Marco Gheza marcogheza4mailinglists at gmail.com
Mon May 17 10:00:48 EDT 2010


Hi,
i'm trying to access every single voxel of a 3d image and change some
values. In particular, i want to change that values that are not black;
every value has to be increased by a value of 100 for example. If a voxel
has value of 10, i want to give it value of 110.

Here is my code:

imageCT->DisconnectPipeline();
for(i=0;i<512;i++)
   {
for(j=0;j<512;j++)
{
for(k=0;k<311;k++)
{
pixelIndex[0] = i;   // x position
pixelIndex[1] = j;   // y position
pixelIndex[2] = k;   // z position

ImageType::PixelType   pixelValuePT = imagePT->GetPixel( pixelIndex );

ImageType::PixelType  newValue = pixelValueCT+100;

if(pixelValueCT!=0)
{
imageCT->SetPixel(   pixelIndex,   newValue  );
}
}
}
   }

This code doesn't do the work well. Do you know how to change it?
Thank you,
bye,

Marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100517/68dfabc1/attachment.htm>


More information about the Insight-users mailing list