<div>Hi,</div><div>i&#39;m working with ITK and my purpose is to segment a gradient 3D image of a CT volume in the best way possible. I have to use smoothed PET volumes  in order to increase precision in segmenting the gradient image. My idea is to modify the gradient image voxel per voxel in particular those voxels that can make more sharp the edges. I wrote a code that accesses to voxels and modifies them. The problem is that a volume is made by a set of slice and  i can&#39;t modify simply the voxel but i must look also to changing slices. </div>
<div>The code is here:</div><div><br></div><div>#include &quot;itkImage.h&quot;</div><div>#include &quot;itkImageFileReader.h&quot;</div><div>#include &quot;itkImageFileWriter.h&quot;</div><div>#include &quot;itkImageToVTKImageFilter.h&quot;</div>
<div>#include &quot;vtkImageViewer.h&quot;</div><div><br></div><div>int main( int argc, char * argv[] )</div><div>{</div><div>  // Verify the number of parameters in the command line</div><div>  if( argc &lt; 3 )</div><div>
    {</div><div>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;</div><div>    std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; inputImageFile  outputImageFile &quot; &lt;&lt; std::endl;</div><div>    return EXIT_FAILURE;</div>
<div>    }</div><div><br></div><div>  typedef short      PixelType;</div><div>  const   unsigned int        Dimension = 3;</div><div>  typedef itk::Image&lt; PixelType, Dimension &gt;    ImageType;</div><div><br></div><div>
  typedef itk::ImageFileReader&lt; ImageType &gt;  ReaderType;</div><div>  typedef itk::ImageFileWriter&lt; ImageType &gt;  WriterType;</div><div> </div><div>  ReaderType::Pointer reader = ReaderType::New();</div><div>  WriterType::Pointer writer = WriterType::New();</div>
<div> </div><div><br></div><div>  // Here we recover the file names from the command line arguments</div><div>  //</div><div>  const char * inputFilename  = argv[1];</div><div>  const char * outputFilename = argv[2];</div>
<div><br></div><div>  reader-&gt;SetFileName( inputFilename  );</div><div><br></div><div><br></div><div>///</div><div>ImageType::Pointer image = reader-&gt;GetOutput();</div><div><br></div><div><br></div><div>  ImageType::IndexType start;</div>
<div>  ImageType::SizeType  size;</div><div><br></div><div>  size[0]  = 100;  // size along X</div><div>  size[1]  = 100;  // size along Y</div><div>  size[2]  = 100;  // size along Z</div><div><br></div><div>  start[0] =   109;  // first index on X</div>
<div>  start[1] =   190;  // first index on Y</div><div>  start[2] =   177;  // first index on Z</div><div><br></div><div>  ImageType::RegionType region;</div><div>  region.SetSize( size );</div><div>  region.SetIndex( start );</div>
<div>  </div><div>  // Pixel data is allocated</div><div>  image-&gt;SetRegions( region );</div><div>  image-&gt;Allocate();</div><div><br></div><div>  ImageType::PixelType  initialValue = 0;</div><div>  image-&gt;FillBuffer( initialValue );</div>
<div><br></div><div>  reader-&gt;Update();</div><div><br></div><div>image-&gt;DisconnectPipeline();</div><div><br></div><div>   ImageType::IndexType pixelIndex;</div><div> </div><div>   int i,j,k;</div><div>   for(i=103;i&lt;203;i++)</div>
<div>   {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>for(j=282;j&lt;382;j++)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>for(k=186;k&lt;286;k++)</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pixelIndex[0] = i;   // x position</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>pixelIndex[1] = j;   // y position</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>pixelIndex[2] = k;   // z position</div><div><br></div><div>//<span class="Apple-tab-span" style="white-space:pre">                        </span>ImageType::PixelType   pixelValue = image-&gt;GetPixel( pixelIndex );</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>image-&gt;SetPixel(   pixelIndex,   256  );</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>   }</div><div><br></div><div>///</div><div><br></div><div>  writer-&gt;SetFileName( outputFilename );</div><div>  writer-&gt;SetInput( image );</div>
<div><br></div><div>  try </div><div>    { </div><div>    writer-&gt;Update(); </div><div>    } </div><div>  catch( itk::ExceptionObject &amp; err ) </div><div>    { </div><div>    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; </div>
<div>    std::cerr &lt;&lt; err &lt;&lt; std::endl; </div><div>    return EXIT_FAILURE;</div><div>    } </div><div>}</div><div><br></div><div><br></div><div>this code is only an example: it draws a 3D rectangle in the image. Imagine you want to modify the edges around liver. I&#39;m not able to modify the desidered voxels using this code.</div>
<div>Does anyone know how to simply access to the voxels in order to modify them?</div><div>Please give an idea, also a raw idea...thanks so much.</div><div>Bye, </div><div>Marco</div>