[Insight-users] use PET volume in order to modify CT segmentation
Marco Gheza
marcogheza4mailinglists at gmail.com
Thu Apr 29 03:58:16 EDT 2010
Hi,
i'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't modify simply the voxel but i must look also to changing slices.
The code is here:
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkImageViewer.h"
int main( int argc, char * argv[] )
{
// Verify the number of parameters in the command line
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile " <<
std::endl;
return EXIT_FAILURE;
}
typedef short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
// Here we recover the file names from the command line arguments
//
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
reader->SetFileName( inputFilename );
///
ImageType::Pointer image = reader->GetOutput();
ImageType::IndexType start;
ImageType::SizeType size;
size[0] = 100; // size along X
size[1] = 100; // size along Y
size[2] = 100; // size along Z
start[0] = 109; // first index on X
start[1] = 190; // first index on Y
start[2] = 177; // first index on Z
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( start );
// Pixel data is allocated
image->SetRegions( region );
image->Allocate();
ImageType::PixelType initialValue = 0;
image->FillBuffer( initialValue );
reader->Update();
image->DisconnectPipeline();
ImageType::IndexType pixelIndex;
int i,j,k;
for(i=103;i<203;i++)
{
for(j=282;j<382;j++)
{
for(k=186;k<286;k++)
{
pixelIndex[0] = i; // x position
pixelIndex[1] = j; // y position
pixelIndex[2] = k; // z position
// ImageType::PixelType pixelValue = image->GetPixel( pixelIndex );
image->SetPixel( pixelIndex, 256 );
}
}
}
///
writer->SetFileName( outputFilename );
writer->SetInput( image );
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
}
this code is only an example: it draws a 3D rectangle in the image. Imagine
you want to modify the edges around liver. I'm not able to modify the
desidered voxels using this code.
Does anyone know how to simply access to the voxels in order to modify them?
Please give an idea, also a raw idea...thanks so much.
Bye,
Marco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100429/052c557f/attachment.htm>
More information about the Insight-users
mailing list