[vtkusers] Trying to connect ITK - VTK - ITK

Bc. Michal Srna michal at srna.info
Mon Apr 11 11:16:58 EDT 2011


Tried, but didn't help.

I also tried to use simple example from
http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf (slide 18) and
tried just to connect simple readed 2D tiff image (via ITK) to the VTK
pipeline via ImageToVTKImageFilter like this:

typedef itk::Image<unsigned short,2> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;

ReaderType::Pointer reader= ReaderType::New();
ConnectorType::Pointer connector= ConnectorType::New();

reader->SetFileName( argv[1]);
connector->SetInput( reader->GetOutput() );

connector-> Update ();

Code runs, no compile errors and when running it crashes on the same spot in
file vtkImageImport.cxx just when executing "connector-> Update ()". So the
problem is somewhere where executing connection of ITK pipeline to the VTK
pipeline.

Here is the report of crash:

First-chance exception at 0x01e1e219 in test.exe: 0xC0000005: Access
violation reading location 0x00000000.
Unhandled exception at 0x01e1e219 in test.exe: 0xC0000005: Access violation
reading location 0x00000000.
The program '[3968] test.exe: Native' has exited with code 0 (0x0).



2011/4/11 Bill Lorensen <bill.lorensen at gmail.com>

> Try changing:
>
>   blend->SetInput(0,connector_ITK_to_VTK_alpha_data2->GetOutput());
> to
>   blend->SetInput(1,connector_ITK_to_VTK_alpha_data2->GetOutput());
>
>
> On Mon, Apr 11, 2011 at 10:15 AM, Michal Srna <kositch at seznam.cz> wrote:
>
>> Hello dear VTK users,
>>
>> I would like to connect two 3D images from ITK (same dimensions) to VTK
>> and blend them using vtkImageBlend. The problem is, that when I run the
>> code, it crashes on this part of the code of vtkImageImport.cxx
>>
>>  if (this->WholeExtentCallback)
>>    {
>>    tryCatchMacro(
>>      this->SetWholeExtent(
>> ->        (this->WholeExtentCallback)(this->CallbackUserData)),
>>      "Calling WholeExtentCallback: ");
>>    }
>>
>> Here is my corresponding code.  "TransformedImportFilter" and
>>  "FixedImportFilter" are outputs of ITKImageFilter, which connects my image
>> data from memory into the ITK pipeline:
>>
>>                          /*connecting ITK to VTK*/
>>                                typedef itk::ImageToVTKImageFilter<
>> TransformedImageType > ITK_to_VTK_ConnectorType;
>>
>>                                ITK_to_VTK_ConnectorType::Pointer
>> connector_ITK_to_VTK_alpha_data1 = ITK_to_VTK_ConnectorType::New();
>>                                ITK_to_VTK_ConnectorType::Pointer
>> connector_ITK_to_VTK_alpha_data2 = ITK_to_VTK_ConnectorType::New();
>>
>>                                connector_ITK_to_VTK_alpha_data1->SetInput(
>> TransformedImportFilter->GetOutput() );
>>                                connector_ITK_to_VTK_alpha_data2->SetInput(
>> FixedImportFilter->GetOutput() );
>>
>>                        /*blending image data*/
>>                                vtkSmartPointer<vtkImageBlend> blend =
>> vtkSmartPointer<vtkImageBlend>::New();
>>                                blend->SetOpacity(0, 0.5);
>>                                blend->SetOpacity(1, 0.5);
>>
>>  blend->SetInput(0,connector_ITK_to_VTK_alpha_data1->GetOutput());
>>
>>  blend->SetInput(0,connector_ITK_to_VTK_alpha_data2->GetOutput());
>>
>>                        /*connecting VTK to ITK*/
>>                                typedef itk::VTKImageToImageFilter<
>> TransformedImageType > VTK_to_ITK_ConnectorType;
>>
>>                                VTK_to_ITK_ConnectorType::Pointer
>> connector_VTK_to_ITK = VTK_to_ITK_ConnectorType::New();
>>
>>                                connector_VTK_to_ITK->SetInput(
>> blend->GetOutput() );
>>
>>                        /*writing the data into DICOM*/
>>                                typedef itk::ImageFileWriter<
>> TransformedImageType > WriterType;
>>                                WriterType::Pointer writer =
>> WriterType::New();
>>
>>  writer->SetFileName(output_alpha_visualization);
>>
>>  writer->SetInput(connector_VTK_to_ITK->GetOutput() );
>>                                writer->Update();
>>
>> I think the problem is already in process of importing data from ITK to
>> VTK. I am using ITKv4 and VTK 5.6.1 on Windows platform with MVSC++.
>>
>> I will be happy, if someone will help me.
>>
>> Best regards,
>>
>> Pavli
>> _______________________________________________
>> 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
>>
>
>


-- 
S pozdravem Bc. Michal Srna

Fotografické portfolio:
http://michalsrna.cz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110411/0d6e2315/attachment.htm>


More information about the vtkusers mailing list