[Insight-users] Fwd: [vtkusers] Trying to connect ITK - VTK - ITK

Bc. Michal Srna michal at srna.info
Mon Apr 11 12:03:22 EDT 2011


Thanks for yout suggestion - thanks to Bill - solved now. I needed to
compile ITKv4 again with flag ITKGroup_Bridge flag turned on. (Before than I
was using ITKBasicFilters.lib from build of ITK 3.20, which is probably not
compatible with new ITKv4)

Thanks!

2011/4/11 Garin, Alba <agarin at ceit.es>

Hi ,
>
>
>
> Are you sure that the reader does its function correctly? Because I use
> this filter in the same way as you do and I do not get any error. I would
> save the output of the reader in an image and set as input this image in
> order to separate both actions. Try it, look if you save the image properly
> and see if gives the error in the same place as before. Because maybe this
> filter executes the reader->getoutput when updating and not when setting the
> input. Don’t know.
>
> Hope it helps.
>
>
>
> Alba
>
>
>
>
>
> *From:* insight-users-bounces at itk.org [mailto:
> insight-users-bounces at itk.org] *On Behalf Of *Bc. Michal Srna
> *Sent:* lunes, 11 de abril de 2011 17:32
> *To:* Bill Lorensen
> *Cc:* insight-users at itk.org; vtkusers at vtk.org
> *Subject:* Re: [Insight-users] [vtkusers] Trying to connect ITK - VTK -
> ITK
>
>
>
> Did it, no error message at all (I use console application).
>
> Here I marked, where the program crashes in file vtkImageImport.cxx, it's
> on line 7
>
> 1void vtkImageImport::InvokeExecuteInformationCallbacks()
> 2{
> 3  if (this->WholeExtentCallback)
> 4    {
> 5   tryCatchMacro(
> 6      this->SetWholeExtent(
> 7        (this->WholeExtentCallback)(this->CallbackUserData)),
> 8      "Calling WholeExtentCallback: ");
> 9   }
>
> 2011/4/11 Bill Lorensen <bill.lorensen at gmail.com>
>
> Put a try/catch around the Update();
>
>
>
> On Mon, Apr 11, 2011 at 11:16 AM, Bc. Michal Srna <michal at srna.info>
> wrote:
>
> 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
>
>
>
>
>
>
> --
> S pozdravem Bc. Michal Srna
>
> Fotografické portfolio:
> http://michalsrna.cz
>



-- 
S pozdravem Bc. Michal Srna

Fotografické portfolio:
http://michalsrna.cz



-- 
S pozdravem Bc. Michal Srna

Fotografické portfolio:
http://michalsrna.cz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110411/31d29108/attachment.htm>


More information about the Insight-users mailing list