如何将DICOM ITK阅读器输出作为qt中itk过滤器qaction按钮的输入?

时间:2017-05-11 06:11:13

标签: vtk itk

     MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
            {
            ui->setupUi(this);
            connect(ui->actionDICOM_Sequence, SIGNAL(triggered()), this, SLOT(DICOMseq()));
            connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
            connect(ui->actionCanny_2, SIGNAL(triggered()), this, SLOT(canny()));
            connect(ui->actionScript_window, SIGNAL(triggered()), this, SLOT(script()));
            }
        MainWindow::~MainWindow()
        {
            delete ui;
        }

        int MainWindow::DICOMseq()
        {


            typedef double InputPixelType;

//像素类型

const unsigned int InputDimension = 3;

//图像尺寸

typedef itk::Image< InputPixelType, 3 > InputImageType;

//图片类型

typedef itk::ImageSeriesReader< InputImageType > ReaderType;

//图像类型的阅读器

ReaderType::Pointer reader = ReaderType::New();

//替换ITK的名称生成器

 QDir dir("Dir");
                        dir = QFileDialog::getExistingDirectory(0, "  ");
                        QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);

                        std::vector<std::string> names;
                        foreach(QFileInfo finfo, list)
                        {
                            std::string str = dir.path().toStdString().c_str();
                            str = str + "/";
                            names.push_back(str + finfo.fileName().toStdString().c_str());
                        }

                        reader->SetFileNames(names);

//卓越的处理

 try
                        {
                            reader->Update();
                        }
                        catch (itk::ExceptionObject & e)
                        {
                            std::cerr << "exception in file reader " << std::endl;
                            std::cerr << e << std::endl;
                            return EXIT_FAILURE;
                        }

//将ITK图像数据转换为VTK图像数据的连接器

  typedef itk::ImageToVTKImageFilter<InputImageType > ConnectorType;
                        ConnectorType::Pointer connector = ConnectorType::New();


 connector->SetInput(reader->GetOutput());

                try
                {
                    connector->Update();
                }
                catch (itk::ExceptionObject & e)
                {
                    std::cerr << "exception in file reader " << std::endl;
                    std::cerr << e << std::endl;
                    return EXIT_FAILURE;
                }

        vtkImageData * image = vtkImageData::New();
            image->DeepCopy(connector->GetOutput());

        vtkInteractorStyleImage *style = vtkInteractorStyleImage::New();
            renderWindowInteractor1->SetInteractorStyle(style);
            viewer1->SetupInteractor(renderWindowInteractor1);
            viewer1->SetInputData(image);
            viewer1->SetSliceOrientationToXY();
            viewer1->GetRenderer()->ResetCamera();
            ui->qvtkWidget->SetRenderWindow(viewer1->GetRenderWindow());
            ui->qvtkWidget->GetRenderWindow()->Render();
        return EXIT_SUCCESS;
        }

void MainWindow::canny()
{

//我应该首先在这里编码以从上面的DICOMseq()获取dicom图像阅读器输出并应用canny检测itk代码//     }

0 个答案:

没有答案