[ITK] when using itkImageFileReader to read dicom image , it occurs assertion failure:pixeltype_debug==pixeltype.
Jon Haitz Legarreta
jhlegarreta at vicomtech.org
Thu Mar 19 12:11:28 EDT 2015
Dear Guirong,
DICOM images most commonly use short pixel types.
The error says that there is some problem with the pixel type you specified.
HTH,
JON HAITZ
On 19 March 2015 at 16:44, 转身转瞬 <1549917255 at qq.com> wrote:
> Hi,everyone,
> I'm using ITK to read CTA image(it's a kind of dicom image),and when
> it runs to the update ,the following error happens:
> in command line:Assertion failed:pixeltype_debug==pixeltype.
> file..\..\..\..\..\InsightToolkit-4.4.0\Modules\IO\GDCM\src\itkGDCMImageIO.cxx,line
> 287
>
> in a window:
> Debug Error!
> Program:F:\..\..\..\helloworld7.exe
> R6010
> -abort() has been called
> (Press Retry to debug the application)
>
>
> My code is as follows:
> #include"itkImage.h"
> #include"itkImageFileReader.h"
> #include"itkImageToVTKImageFilter.h"
> #include<itkGDCMImageIO.h>
> #include"vtkImageViewer.h"
> #include"vtkRenderWindowInteractor.h"
> #include"vtkSmartPointer.h"
> #include"vtkImageFlip.h"
> #include"vtkRenderer.h"
> #include"vtkImageActor.h"
> #include"vtkCamera.h"
> #include"vtkImageMapper.h"
> using namespace std;
> int main()
> {
> typedef itk::Image<unsigned char,2> ImageType;
> typedef itk::ImageFileReader<ImageType> ReaderType;
> ReaderType::Pointer reader=ReaderType::New();
> //获得DICOM文件读取对象
> typedef itk::GDCMImageIO ImageIOType;
> ImageIOType::Pointer gdcmImageIO=ImageIOType::New();
> //Filter of itk image data to vtk image data;
> typedef itk::ImageToVTKImageFilter<ImageType> FilterType;
> FilterType::Pointer connector=FilterType::New();
> //获得DICOM文件名并读取DICOM文件;
>
> char*DICOMName="F://c++projects//helloworld6//1.3.12.2.1107.5.1.4.60540.30000013102023122056200010862";
> reader->SetFileName(DICOMName);
> reader->SetImageIO(gdcmImageIO);
> cout<<"done0"<<endl;
> //ITK到VTK转化
> connector->SetInput(reader->GetOutput());
> cout<<"done1"<<endl;
> *connector->Update();//This is the place where error occurs!*
> cout<<"done2"<<endl;
> vtkSmartPointer<vtkImageFlip>flip=vtkSmartPointer<vtkImageFlip>::New();
> //vtkSmartPointer<vtkImageMapper>
> flip->SetInput(connector->GetOutput());
> flip->SetFilteredAxis(1);
> //需要进行上下翻转才能正确显示;
> flip->Update();
>
> vtkSmartPointer<vtkImageActor>actor=vtkSmartPointer<vtkImageActor>::New();
> actor->SetInput(flip->GetOutput());
> actor->InterpolateOff();
> vtkSmartPointer<vtkRenderer>renderer=vtkSmartPointer<vtkRenderer>::New();
> renderer->AddActor(actor);
>
>
> vtkSmartPointer<vtkRenderWindow>renderWindow=vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
> vtkRenderWindowInteractor*iren=vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renderWindow);
> iren->Initialize();
> iren->Start();
> return 0;
> }
> If anyone know how to fix this, could you please just help me?
> Thanks a lot.
>
> Guirong Liu
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150319/19641627/attachment.html>
More information about the Community
mailing list