本代码用ITK实现了DICOM图像 到 BMP图像的转换 并使用亮度调节转换出成像效果较好的 BMP图像。(代码中写死的文件位置,也可以通过输入路径参数来控制文件)
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkGDCMImageIO.h"
#include "itkBMPImageIO.h"
#include "itkCastImageFilter.h"
int main()
{
//定义输入的类型
typedef signed short InputPixelType;
const unsigned int inputDimension = 2;
typedef itk::Image<InputPixelType,inputDimension> InputImageType;
//设置输入的DCM图像
typedef itk::ImageFileReader < InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName("CTAtt009_CT001.dcm");
//设置DCM类型
typedef itk::GDCMImageIO Imageiotype;
Imageiotype::Pointer gdcmImageIo = Imageiotype::New();
reader->SetImageIO( gdcmImageIo );
try
{
reader->Update();
}
catch (itk::ExceptionObject &