first commit
This commit is contained in:
122
src/include/export/dicomexporter.h
Normal file
122
src/include/export/dicomexporter.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef DICOMEXPORTER_H
|
||||
#define DICOMEXPORTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "exportoptions.h"
|
||||
#include <itkImage.h>
|
||||
#include <itkGDCMImageIO.h>
|
||||
#include <itkImageSeriesReader.h>
|
||||
#include <itkImageSeriesWriter.h>
|
||||
#include <itkImageToVTKImageFilter.h>
|
||||
#include <itkGDCMSeriesFileNames.h>
|
||||
#include "base/infinitiViewer.h"
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkCornerAnnotation.h>
|
||||
#include <vtkWindowToImageFilter.h>
|
||||
#include <vtkImageCast.h>
|
||||
#include <vtkPNGWriter.h>
|
||||
#include <vtkBMPWriter.h>
|
||||
#include <vtkJPEGWriter.h>
|
||||
#include <vtkTIFFWriter.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qdir.h>
|
||||
#include <sstream>
|
||||
#include "itkMetaDataObject.h"
|
||||
#include "itkMetaDataDictionary.h"
|
||||
|
||||
|
||||
class DicomExporter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
enum FileType
|
||||
{
|
||||
SingleFile,
|
||||
DirType,
|
||||
NonType,
|
||||
|
||||
};
|
||||
public:
|
||||
explicit DicomExporter(QObject *parent = nullptr);
|
||||
|
||||
void execute(ExportOptions options);
|
||||
|
||||
signals:
|
||||
void exportFinished();
|
||||
void exportProgress(int total, int progress);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
private:
|
||||
//dicom tags
|
||||
const std::string TAG_WindowLevel = "0028|1050";
|
||||
const std::string TAG_WindowWidth = "0028|1051";
|
||||
|
||||
//anonymization
|
||||
const std::string TAG_InstitutionName = "0008|0080";
|
||||
const std::string TAG_InstitutionAddress = "0008|0081";
|
||||
const std::string TAG_ReferringPhysicianName = "0008|0090";
|
||||
const std::string TAG_OperatorsName = "0008|1070";
|
||||
const std::string TAG_PatientAddress = "0010|1040";
|
||||
const std::string TAG_PatientTelephoneNumbers = "0010|2154";
|
||||
const std::string TAG_OtherPatientNames = "0010|1001";
|
||||
const std::string TAG_OtherPatientIDs = "0010|1000";
|
||||
const std::string TAG_OtherPatientIDsSequence = "0010|1002";
|
||||
const std::string TAG_PatientName = "0010|0010";
|
||||
const std::string TAG_PatientBirthDate = "0010|0030";
|
||||
const std::string TAG_PatientSex = "0010|0040";
|
||||
const std::string TAG_PatientAge = "0010|1010";
|
||||
const std::string TAG_PatientID = "0010|0020";
|
||||
const std::string TAG_AccessionNumber = "0008|0050";
|
||||
|
||||
//bmp jpg png tiff exprt releated objects
|
||||
static const unsigned int InputDimensionExport = 3;
|
||||
typedef signed short PixelTypeExport;
|
||||
typedef itk::Image<PixelTypeExport, InputDimensionExport> InputImageTypeExport;
|
||||
typedef itk::GDCMImageIO ImageIOTypeExport;
|
||||
typedef itk::ImageSeriesReader<InputImageTypeExport> SeriesReaderTypeExport;
|
||||
typedef itk::ImageToVTKImageFilter<InputImageTypeExport> ConnectorTypeExport;
|
||||
typedef itk::GDCMSeriesFileNames InputNamesGeneratorTypeExport;
|
||||
|
||||
//dicom export releated objects
|
||||
typedef signed short OutputPixelType;
|
||||
static const unsigned int OutputDimension = 2;
|
||||
typedef itk::Image<OutputPixelType, OutputDimension> Image2DType;
|
||||
typedef itk::ImageSeriesWriter<InputImageTypeExport, Image2DType> SeriesWriterType;
|
||||
|
||||
private:
|
||||
void initVTK();
|
||||
void initDataReader();
|
||||
void loadDicomFileAndRender(int file_type);
|
||||
//void updateCornerInfo(int slice, int maxslice);
|
||||
void doExport(int file_type);
|
||||
QString getFileExtention();
|
||||
void writeToFile(const QString& fileName);
|
||||
void writeToPngFile(vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter, const QString& fileName);
|
||||
void writeToBmpFile(vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter, const QString& fileName);
|
||||
void writeToJpgFile(vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter, const QString& fileName);
|
||||
void writeToTiffFile(vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter, const QString& fileName);
|
||||
void exportPicture(const QString& fileName);
|
||||
void exportDicom(const QString& fileName);
|
||||
void exportSingleDicomFile(const QString& fileName);
|
||||
void exportDicomDirectory(const QString& fileName);
|
||||
void modifyDicomTags(SeriesReaderTypeExport::DictionaryArrayRawPointer dicArray);
|
||||
void caculateExportTotalCount();
|
||||
|
||||
private:
|
||||
ExportOptions exportOptions;
|
||||
int totalCount;//the total count of image to be exported
|
||||
int exportedNumber;//the exported image index
|
||||
|
||||
//itk vtk releated objects
|
||||
ImageIOTypeExport::Pointer m_gdcmIOExport;
|
||||
SeriesReaderTypeExport::Pointer m_itkSeriesReaderExport;
|
||||
ConnectorTypeExport::Pointer m_itkConnectorExport;
|
||||
InputNamesGeneratorTypeExport::Pointer m_inputNamesExport;
|
||||
vtkSmartPointer<vtkRenderWindow> m_glrenWinExport;
|
||||
vtkSmartPointer<infinitiViewer> m_imageViewerExport;
|
||||
};
|
||||
|
||||
#endif // DICOMEXPORTER_H
|
||||
Reference in New Issue
Block a user