-1

when my program run reader->update(); i will be given a microsoft c++ error

Microsoft C++ 异常: itk::ImageFileReaderException,位于内存位置 0x00000000002CF0F8 处。

here is my entire code:

#include "itkImage.h"
#include <iostream>
#include<itkAndImageFilter.h>
#include <itkImageFileReader.h>
#include "itkImageFileWriter.h"
#include<string>

int main()
{
    using PixelType = float;
    constexpr unsigned int Dimension = 3;
    const char* im_path = "C:/Users/Administrator/Desktop/test.nii.gz";
    using ImageType = itk::Image<PixelType, Dimension>;
    using ReaderType = itk::ImageFileReader<ImageType>;
    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName(im_path);
    std::string s = reader->GetFileName();
    std::cout << s << std::endl;
    ImageType::Pointer image = reader->GetOutput();
    reader->Update();
    return 0; 
}
hi_world
  • 1
  • 2
  • What is your question? I think you must read https://stackoverflow.com/help/how-to-ask to ask a good question – mshomali Jan 31 '22 at 08:22
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 31 '22 at 08:22

1 Answers1

1

There is probably something wrong with how you compiled ITK, or how you link your program to ITK. Your program works on my computer without issue. I only changed the path to the file. Make sure the file is not damaged, by opening it in another program such as ITK-SNAP or 3D Slicer.

Dženan
  • 3,329
  • 3
  • 31
  • 44