[Insight-users] runtime error using ITK + VTK + QT (QVTKWidget)
Dominic
dominic.gehweiler at gmx.de
Thu May 2 08:50:00 EDT 2013
Hi,
I am using ItkVTKGlue and vtkImageSlice to display two images (on top of
each other) in QVTKWidget.
When I am using vtkImageData everything works fine. Now I try to use
itkImage instead using ItkVTKGlue.
Everything compiles fine, but I get a runtime error "Access violation when
reading at position 0xffffffffffffffff" a startup at:
void VTKImageExportBase::UpdateInformationCallbackFunction(void *userData)
{
static_cast< VTKImageExportBase * >
( userData )->UpdateInformationCallback();//the error is here
}
Am I doing something wrong?
Thanks a lot in advance!
It follows the crucial part of the code:
...
#include "itkRGBAPixel.h"
#include "itkImage.h"
#include "itkImageRegionIterator.h"
#include "itkImageToVTKImageFilter.h"
typedef itk::RGBAPixel<quint8> PixelType;
typedef itk::Image<PixelType, 2> ImageType;
typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
...
vtkSmartPointer<vtkImageData> DICOMimageMask =
vtkSmartPointer<vtkImageData>::New();
DICOMimageMask->SetExtent(0 , 512 - 1 , 0 , 512 - 1 , 0 , 0);
DICOMimageMask->SetOrigin(0.0 , 0.0 , 0.0);
DICOMimageMask->SetSpacing(1.0 , 1.0 , 1.0);
DICOMimageMask->SetScalarTypeToUnsignedChar();
DICOMimageMask->SetNumberOfScalarComponents(4);
DICOMimageMask->AllocateScalars();
// init Pixels
...
ImageType::RegionType region;
ImageType::IndexType start;
start[0] = 0;
start[1] = 0;
ImageType::SizeType size;
size[0] = 512;
size[1] = 512;
region.SetSize(size);
region.SetIndex(start);
ImageType::Pointer image = ImageType::New();
image->SetRegions(region);
image->Allocate();
// init Pixels
...
FilterType::Pointer connector = FilterType::New();
connector->SetInput(image);
connector->Update();
// this image (imageData) is already initialised
vtkSmartPointer<vtkImageSliceMapper> DICOMimageSliceMapper =
vtkSmartPointer<vtkImageSliceMapper>::New();
DICOMimageSliceMapper->SetInputConnection(imageData->GetProducerPort());
vtkSmartPointer<vtkImageSlice> DICOMimageSlice =
vtkSmartPointer<vtkImageSlice>::New();
DICOMimageSlice->SetMapper(DICOMimageSliceMapper);
DICOMimageSlice->GetProperty()->SetOpacity(1.0);
//DICOMimageSlice->GetProperty()->SetInterpolationType(0);
vtkSmartPointer<vtkImageSliceMapper> DICOMimageMaskSliceMapper =
vtkSmartPointer<vtkImageSliceMapper>::New();
// this of course works
DICOMimageMaskSliceMapper->SetInputConnection(DICOMimageMask->GetProducerPort());
// this doesn't work
DICOMimageMaskSliceMapper->SetInput(connector->GetOutput());
// doesn't work
DICOMimageMask = connector->GetOutput();
DICOMimageMaskSliceMapper->SetInputConnection(DICOMimageMask->GetProducerPort());
// this works, but is not really senseful
DICOMimageMask->DeepCopy(connector->GetOutput());
DICOMimageMaskSliceMapper->SetInputConnection(DICOMimageMask->GetProducerPort());
vtkSmartPointer<vtkImageSlice> DICOMimageMaskSlice =
vtkSmartPointer<vtkImageSlice>::New();
DICOMimageMaskSlice->SetMapper(DICOMimageMaskSliceMapper);
DICOMimageMaskSlice->GetProperty()->SetOpacity(1.0);
DICOMimageMaskSlice->GetProperty()->SetInterpolationType(0);
// Renderer
renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(DICOMimageSlice);
renderer->AddActor(DICOMimageMaskSlice);
//renderer->ResetCamera();
// RenderWindow (from QVTK-Widget)
vtkSmartPointer<vtkRenderWindow> renderWindow =
ui.qvtkWidget->GetRenderWindow();
renderWindow->AddRenderer(renderer);
// RenderWindowInteractor
...
// Picker
...
// Render and start interaction
...
--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/runtime-error-using-ITK-VTK-QT-QVTKWidget-tp7582936.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list