[vtkusers] Error message about vtk

Jothy jothybasu at gmail.com
Wed Nov 3 08:55:00 EDT 2010


Are you setting importer->SetImportVoidPointer(data);

"data" is the output from itk.

I hope you had a look at
http://vtk.org/gitweb?p=VTK.git;a=blob;f=Imaging/Testing/Cxx/ImportExport.cxx

Jothy


On Wed, Nov 3, 2010 at 12:40 PM, Xiaopeng Yang <yxp233 at postech.ac.kr> wrote:

>  Thank you so much for your warmhearted help! My code is kind of huge. Let
> me explain briefly: the program is coded for segmentation using ITK,
> visualization by VTK, and interface by QT. It consists of image loading,
> diffusion filtering, then fast marching segmentation using diffusion
> filtering output as input. I attach the code here and hope you guys can help
> me to find inappropriate part. Thank you very much in advance!
>
>
>
> //connect vtk to itk
>
> template <typename ITK_Exporter, typename VTK_Importer>
>
> void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
>
> {
>
>
> importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
>
>
> importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
>
>   importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
>
>   importer->SetSpacingCallback(exporter->GetSpacingCallback());
>
>   importer->SetOriginCallback(exporter->GetOriginCallback());
>
>   importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
>
>
> importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
>
>
> importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
>
>   importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
>
>   importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
>
>   importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
>
>   importer->SetCallbackUserData(exporter->GetCallbackUserData());
>
> }
>
>
>
> //Paramter definiation
>
> #define N_SEEDS 11
>
>
>
> typedef    float    InputPixelType;
>
> typedef    float    OutputPixelType;
>
> typedef itk::Image< InputPixelType,  3 >   InputImageType;
>
> typedef itk::Image< OutputPixelType, 3 >   OutputImageType;
>
>
>
> typedef itk::ImageSeriesReader< InputImageType >     ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> typedef itk::GDCMImageIO                        ImageIOType;
>
> typedef itk::GDCMSeriesFileNames                NamesGeneratorType;
>
> ImageIOType::Pointer gdcmIO = ImageIOType::New();
>
> NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
>
>
>
> typedef itk::VTKImageExport< OutputImageType > ExportFilterType;
>
>
>
> typedef itk::RescaleIntensityImageFilter<
>
>              OutputImageType, InputImageType > RescaleFilterType;
>
> RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>
>
>
> typedef itk::BinaryThresholdImageFilter< InputImageType,
>
>                     OutputImageType    >    ThresholdingFilterType;
>
>
>
> SimpleView::SimpleView()
>
> {
>
>   this->ui = new Ui_SimpleView;
>
> this->ui->setupUi(this);
>
>   // Set up action signals and slots
>
> connect(this->ui->actionOpen, SIGNAL(triggered()), this,
> SLOT(slotOpen()));
>
> connect(this->ui->pushButton_14, SIGNAL(clicked()), this,
> SLOT(slotContour()));
>
> };
>
>
>
> void SimpleView::slotOpen()
>
> {
>
>
>
>   QString directory = QFileDialog::getExistingDirectory(this,
>
>                                     tr("Choose a directory"),
> QDir::currentPath());
>
>
>
>   namesGenerator->SetInputDirectory(directory);
>
>
>
>   const ReaderType::FileNamesContainer & filenames =
>
>                             namesGenerator->GetInputFileNames();
>
>
>
>   unsigned int numberOfFilenames =  filenames.size();
>
>   std::cout << numberOfFilenames << " images loaded" << std::endl;
>
>   for(unsigned int fni = 0; fni<numberOfFilenames; fni++)
>
>     {
>
>     std::cout << "filename # " << fni << " = ";
>
>     std::cout << filenames[fni] << std::endl;
>
>     }
>
>
>
>   reader->SetImageIO( gdcmIO );
>
>   reader->SetFileNames( filenames );
>
>
>
>   //reader->Update();
>
>
>
>   //Diffusion filter
>
>   typedef itk::GradientAnisotropicDiffusionImageFilter<
>
>                InputImageType, OutputImageType >  FilterType;
>
>   FilterType::Pointer filter = FilterType::New();
>
>
>
>   filter->SetInput( reader->GetOutput() );
>
>
>
>   // Set parameters for diffusion filter
>
>   const unsigned int numberOfIterations = 5;
>
>   const double       timeStep = 0.0625;
>
>   const double       conductance = 3;
>
>
>
>   filter->SetNumberOfIterations( numberOfIterations );
>
>   filter->SetTimeStep( timeStep );
>
>   filter->SetConductanceParameter( conductance );
>
>
>
>   filter->Update();
>
>
>
>   RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>
>   rescaler->SetOutputMinimum(   0 );
>
>   rescaler->SetOutputMaximum( 255 );
>
>
>
> rescaler->SetInput( filter->GetOutput() );
>
> }
>
>
>
> void SimpleView::slotContour() {
>
>
>
>
>
>   long int seed_points[N_SEEDS][3] = {
>
>                                                             {     186,
> 206, 138    },
>
>                                                             {     138,
> 218, 124    },
>
>                                                             {     226,
> 201, 124    },
>
>                                                             {     309,
> 220, 124    },
>
>                                                             {     147,
> 305, 83     },
>
>                                                             {     111,
> 228, 83     },
>
>                                                             {     171,
> 176, 83     },
>
>                                                             {     245,
> 178, 83     },
>
>                                                             {     202,
> 243, 83     },
>
>                                                             {     112,
> 242, 45     },
>
>                                                             {     98,  253,
> 7 }
>
>                                                         };
>
>
>
>   const InputPixelType  timeThreshold = 85;
>
>
>
>   ThresholdingFilterType::Pointer thresholder1 =
> ThresholdingFilterType::New();
>
>   thresholder1->SetLowerThreshold(           0.0  );
>
>   thresholder1->SetUpperThreshold( timeThreshold  );
>
>   thresholder1->SetOutsideValue(  0  );
>
>   thresholder1->SetInsideValue(  255 );
>
>
>
>   typedef   itk::GradientMagnitudeRecursiveGaussianImageFilter<
>
>                                InputImageType,
>
>                                InputImageType >  GradientFilterType;
>
>
>
>   typedef   itk::SigmoidImageFilter<
>
>                                InputImageType,
>
>                                InputImageType >  SigmoidFilterType;
>
>
>
>   GradientFilterType::Pointer  gradientMagnitude =
> GradientFilterType::New();
>
>
>
>   SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
>
>
>
>   sigmoid->SetOutputMinimum(  0.0  );
>
>   sigmoid->SetOutputMaximum(  1.0  );
>
>
>
>   typedef  itk::FastMarchingImageFilter< InputImageType,
>
>                               InputImageType >    FastMarchingFilterType;
>
>
>
>   FastMarchingFilterType::Pointer  fastMarching =
> FastMarchingFilterType::New();
>
>
>
>   gradientMagnitude->SetInput( rescaler->GetOutput() ); // using rescaler
> from diffusion filter as input
>
>   sigmoid->SetInput( gradientMagnitude->GetOutput() );
>
>   fastMarching->SetInput( sigmoid->GetOutput() );
>
>   thresholder1->SetInput( fastMarching->GetOutput() );
>
>   //thresholder1->Update();
>
>
>
>   const double sigma = 1.3;
>
>
>
>   gradientMagnitude->SetSigma(  sigma  );
>
>
>
>   const double alpha =  -0.05;
>
>   const double beta =  0.3;
>
>
>
>   sigmoid->SetAlpha( alpha );
>
>   sigmoid->SetBeta(  beta  );
>
>
>
>   typedef FastMarchingFilterType::NodeContainer           NodeContainer;
>
>   typedef FastMarchingFilterType::NodeType                NodeType;
>
>   NodeContainer::Pointer seeds = NodeContainer::New();
>
>
>
>   InputImageType::IndexType  seedPosition, seedPosition2;
>
>   const double initialDistance = 2.0;
>
>
>
>   NodeType node, node1, node2;
>
>   const double seedValue = -1*initialDistance;
>
>
>
>   for (int i = 0; i<N_SEEDS; i++)   {
>
>       seedPosition[0] = seed_points[i][0];
>
>       seedPosition[1] = seed_points[i][1];
>
>       seedPosition[2] = seed_points[i][2];
>
>       node.SetValue( seedValue );
>
>       node.SetIndex( seedPosition );
>
>       seeds->InsertElement( i, node );
>
>       std::cout << "Seed Position " << seedPosition << std::endl;
>
>   }
>
>
>
>   fastMarching->SetTrialPoints(  seeds  );
>
>
>
>   fastMarching->SetOutputSize(
>
>            reader->GetOutput()->GetBufferedRegion().GetSize() );
>
>
>
>   const double stoppingTime = 100;
>
>
>
>   fastMarching->SetStoppingValue(  stoppingTime  );
>
>
>
>   ExportFilterType::Pointer itkExporter2 = ExportFilterType::New();
>
>
>
>   itkExporter2->SetInput( thresholder1->GetOutput() );
>
>
>
>   vtkImageImport* vtkImporter2 = vtkImageImport::New();
>
>   ConnectPipelines(itkExporter2, vtkImporter2);
>
>
>
>   vtkImageViewer2 *imageViewer = vtkImageViewer2::New();
>
>   this->ui->qvtkWidget->SetRenderWindow(imageViewer->GetRenderWindow());
>
>
>
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>
>
>
>   imageViewer->SetupInteractor(iren);
>
>   imageViewer->SetInput(vtkImporter2->GetOutput());
>
>   imageViewer->SetColorLevel(127);
>
>   imageViewer->SetColorWindow(255);
>
>
>
>   imageViewer->Render();
>
>   imageViewer->GetRenderer()->ResetCamera();
>
>
>
>   vtkSliderRepresentation2D *SliderRepres =
> vtkSliderRepresentation2D::New();
>
>   int min = imageViewer->GetSliceMin();
>
>   int max = imageViewer->GetSliceMax();
>
>   SliderRepres->SetMinimumValue(min);
>
>   SliderRepres->SetMaximumValue(max);
>
>   SliderRepres->SetValue(static_cast<int>((min + max) / 2));
>
>
>
>
> SliderRepres->GetPoint1Coordinate()->SetCoordinateSystemToNormalizedDisplay();
>
>   SliderRepres->GetPoint1Coordinate()->SetValue(0.92, 0.9);
>
>
> SliderRepres->GetPoint2Coordinate()->SetCoordinateSystemToNormalizedDisplay();
>
>   SliderRepres->GetPoint2Coordinate()->SetValue(0.92, 0.1);
>
>   SliderRepres->SetSliderLength(0.03);
>
>   SliderRepres->SetSliderWidth(0.03);
>
>   SliderRepres->SetEndCapLength(0.03);
>
>   SliderRepres->SetEndCapWidth(0.05);
>
>   SliderRepres->SetTubeWidth(0.005);
>
>   SliderRepres->SetLabelFormat("%3.0lf");
>
>   SliderRepres->SetTitleHeight(0.05);
>
>   SliderRepres->SetLabelHeight(0.05);
>
>
>
>   vtkSliderWidget *SliderWidget = vtkSliderWidget::New();
>
>   SliderWidget->SetInteractor(iren);
>
>   SliderWidget->SetRepresentation(SliderRepres);
>
>   SliderWidget->KeyPressActivationOff();
>
>   SliderWidget->SetAnimationModeToAnimate();
>
>   SliderWidget->SetEnabled(true);
>
>
>
>   vtkSliderCallback2 *SliderCb = vtkSliderCallback2::New();
>
>   SliderCb->SetImageViewer(imageViewer);
>
>   SliderWidget->AddObserver(vtkCommand::InteractionEvent, SliderCb);
>
>
>
>   imageViewer->SetSlice(static_cast<int>(SliderRepres->GetValue()));
>
> imageViewer->SetSliceOrientationToXY();
>
>
>
> SliderRepres->Delete();
>
> SliderCb->Delete();
>
> iren->Start();
>
> iren->Delete();
>
> }
>
>
>
> *发件人**:* Jothy [mailto:jothybasu at gmail.com]
> *发送时间:* 2010년 11월 3일 수요일 오후 9:15
> *收件人:* Xiaopeng Yang
> *抄送:* vtk
> *主题:* Re: [vtkusers] Error message about vtk
>
>
>
> You could post the code snippet, so that ppl can look into it to help you
> better!
>
> Jothy
>
> On Wed, Nov 3, 2010 at 11:54 AM, Xiaopeng Yang <yxp233 at postech.ac.kr>
> wrote:
>
> Dear All,
>
>
>
> About the error message I mentioned in the last email. Did anybody know
> what causes the probem?
>
>
>
> Best regards,
>
> Yang
>
>
>
> *发件人**:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *代表 *Xiaopeng
> Yang
> *发送时间:* 2010년 11월 3일 수요일 오전 10:22
> *收件人:* 'vtk'
> *主题:* [vtkusers] Error message about vtk
>
>
>
> Hi
>
>
>
> I got the following error when I run a segmentation algorithm. Could anyone
> explain the cause of this error?
>
>
>
> Thanks,
>
> Xiaopeng
>
>
>
> [image: Untitled.png]
>
>
> _______________________________________________
> 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/20101103/4c650f55/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 24261 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101103/4c650f55/attachment.png>


More information about the vtkusers mailing list