[vtkusers] problem in combining two mhd images

Bill Lorensen bill.lorensen at gmail.com
Fri Oct 19 10:11:07 EDT 2012


As the error message reports, image blend requires that both images be of
the same tip. In your case, one image is double and the other if unsigned
short.

Use vtkImageCast to cast the ushort image to double. then pass that to
ImageBlend.

On Thu, Oct 18, 2012 at 8:36 AM, Raviteja, Allaparthi <
Allaparthi.Raviteja at philips.com> wrote:

>  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.****
>
> _______________________________________________
> 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
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121019/6f9a1d63/attachment.htm>


More information about the vtkusers mailing list