[vtkusers] Adding image writer to the pipeline gets itk reader fails
fotosentido at gmail.com
Fri Aug 15 07:03:46 EDT 2014
Well, now I don't understand at all.
The problem with itk ImageFileReader doesn't occur when I add the writer to
the pipeline... it's when I create the vtkJPEGWriter!!!!
vtkJPEGWriter* writer = vtkJPEGWriter::New();
is the problem.
Why?? It has nothing to do with the reading of the file!! It doesn't
execute, it's in another function I don't use at that moment!
I comment that line -and all the next with that object- I can read the file.
I just add that line: itkImageFileReader fails!!!
I'm just wasting a lot of time with this.
2014-08-13 12:56 GMT+02:00 Marcos <fotosentido at gmail.com>:
> I wonder if somebody could help me, I'm stuck with this. Sorry if this was
> asked before, I didn't find anything similar.
> I got a simple pipeline working, starting with a itk::ImageFileReader who
> connects to a vtkImageImport, passing through a vtkImageViewer and ending
> in a QVTKWidget.
> Great. I see an image in my QVTKWidget.
> Now, writing to a file. Let's say a JPEG file.
> I tried with a vtkWindowToImageFilter and a vtkJPEGWriter.
> And that's where the weird things take place: the itk::ImageFileReader
> fails trying to read the file; a segmentation fault in the Update() method.
> Why? It's the same file, and the new code is added after.
> I guess it is related to the pipeline, but I don't get how the end of
> pipeline affects the beginning. Well, I know the Update method from the
> first object could update the whole pipeline.
> So I tried isolating the last part in a method, which is called from a
> menu option: in my application, I "open" the file. I see a image in my
> viewer. Then, later, I choose to export the image I see to a file. It's not
> until that moment that I create the vtkWindowToImageFilter and
> vtkJPEGWriter objects.
> But itk::ImageFileReader fails again. If I comment the last lines, it
> works again.
> Here is the code, simplified (reader is a global variable: when I call
> connectVTKWidget, it has called successfully (before I added the writing
> part) the Update method and I can see a image in the widget):
> void DCMBase::connectVTKWidget(QVTKWidget* widget)
> typedef itk::Image< signed short, 2 > TipoImagen;
> typedef itk::ImageFileReader< TipoImagen > Tiporeader;
> Tiporeader::Pointer reader;
> typedef itk::VTKImageExport< TipoImagen > TipoImagenExport;
> TipoImagenExport::Pointer exporter = TipoImagenExport::New();
> vtkImageImport *imageImport = vtkImageImport::New();
> this->ConnectPipelines(exporter, imageImport);
> vtkImageViewer* imageViewer = vtkImageViewer::New();
> // with this, itk::ImageFileReader fails!
> vtkWindowToImageFilter* filtroAImagen = vtkWindowToImageFilter::New();
> vtkJPEGWriter* writer = vtkJPEGWriter::New();
> // writer->SetInputConnection(alg->GetOutputPort());
> catch (itk::ExceptionObject& e)
> std::cerr << "Excepción en escritura:" <<std::endl;
> std::cerr << e << std::endl;
> Am I missing something? Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers