[vtkusers] vtkImageData - translating the origin
Dženan Zukić
dzenanz at gmail.com
Fri Dec 23 04:19:20 EST 2011
I think in VTK the origin is the lower-left corner.
On Fri, Dec 23, 2011 at 09:18, emreturkoz <emreturkoz at gmail.com> wrote:
> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111223/03a7ad40/attachment.htm>
More information about the vtkusers
mailing list