[vtkusers] problem in combining two mhd images

Raviteja, Allaparthi Allaparthi.Raviteja at philips.com
Thu Oct 18 08:36:26 EDT 2012


Hi,
I am new to VTK and I have a problem in combining two "mhd" images . The code and the error are as follows.
#include <vtkMetaImageReader.h>
#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include <vtkImageViewer2.h>
#include <vtkImageBlend.h>
#include <string>
int main ( int argc, char* argv[] )
{
  // Parse input arguments
  if ( argc != 3 )
    {
    std::cerr << "Usage: " << argv[0]
              << " Input1Filename Input2Filename" << std::endl;
    return EXIT_FAILURE;
    }

  std::string input1Filename = argv[1];
  std::string input2Filename = argv[2];
 // Read the images
  vtkSmartPointer<vtkMetaImageReader> MetaImageReader1 =
    vtkSmartPointer<vtkMetaImageReader>::New();
MetaImageReader1->SetFileName ( input1Filename.c_str() );
 vtkSmartPointer<vtkMetaImageReader> MetaImageReader2 =
    vtkSmartPointer<vtkMetaImageReader>::New();
MetaImageReader2->SetFileName ( input2Filename.c_str() );
  // Combine the images (blend takes multiple connections on the 0th input port)
  vtkSmartPointer<vtkImageBlend> blend =
    vtkSmartPointer<vtkImageBlend>::New();
  blend->AddInputConnection(MetaImageReader1->GetOutputPort());
  blend->AddInputConnection(MetaImageReader2->GetOutputPort());
  blend->SetOpacity(0,.5);
  blend->SetOpacity(1,.5);
 // Display the result
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
 vtkSmartPointer<vtkImageViewer2> imageViewer =
    vtkSmartPointer<vtkImageViewer2>::New();
  imageViewer->SetInputConnection(blend->GetOutputPort());
  imageViewer->SetupInteractor(renderWindowInteractor);
  imageViewer->GetRenderer()->ResetCamera();
  imageViewer->GetRenderer()->SetBackground(1,0,0); //red
 renderWindowInteractor->Initialize();
  renderWindowInteractor->Start();
 return EXIT_SUCCESS;
}
ERROR: In C:\VTK-5.10.0\VTK\Imaging\vtkImageBlend.cxx, line 913
VTKImageBlend[00B6FD18]:Execute:input1 ScalarType [11],must match output ScalarType [5]
How do I resolve the above error?  I am attaching the two input "mhd" files. Could Someone Please help me out.
Thank you.
Regards,
Ravi Teja.



________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121018/a2a9e644/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parabolaclubbedwithline.mhd
Type: application/octet-stream
Size: 334 bytes
Desc: parabolaclubbedwithline.mhd
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121018/a2a9e644/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: drawingshapes.mhd
Type: application/octet-stream
Size: 316 bytes
Desc: drawingshapes.mhd
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121018/a2a9e644/attachment-0001.obj>


More information about the vtkusers mailing list