[vtkusers] vtkImageData - translating the origin
emreturkoz
emreturkoz at gmail.com
Fri Dec 23 03:18:12 EST 2011
I have a set of DICOM images which I read using ITK capabilities and convert
into a VTK image then visualize using vtkImageViewer2.
I want to create a new image data and visualize these two datasets together
in one window. The problem is that the origin of the image that I created is
always located on the lower end corner of the first image. I tried
"SetOrigin" of image data but it doesn't work. What should I do to change
the origin of the image? I use the following code:
vtkImageData *image = vtkImageData::New();
image->SetExtent(0,60,0,60,0,7);
image->SetOrigin(10,10,4);
image->SetDimensions(61,61,8);
image->SetSpacing(1,1,1);
image->Update();
int* dims = image->GetDimensions();
for (int z = 0; z < dims[2]; z++)
{
for (int y = 0; y < dims[1]; y++)
{
for (int x = 0; x < dims[0]; x++)
{
double* pixel = static_cast<double*>(image->GetScalarPointer(x,y,z));
pixel[0] = 120;
pixel[1] = 255;
pixel[2] = 120;
}
}
}
image->SetScalarType(4);
vtkImageBlend *blend = vtkImageBlend::New();
blend->AddInput(itkvtkglue->GetOutput());
blend->AddInput(image);
blend->PRESERVES_RANGES();
blend->SetOpacity(0,1.0);
blend->SetOpacity(1,.4);
pViewerXY->SetInput(blend->GetOutput());
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkImageData-translating-the-origin-tp5096590p5096590.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list