五、dcmimage程序库
dcmimage模块为dcmimgle模块提供对彩色图像的支持。对单色图像的支持由dcmimgle提供,对JPEG压缩图像的支持由dcmjpeg模块支持。
主要接口类:
--DicomImage: 在dcmimgle中已介绍。
工具:
--dcm2pnm: Convert DICOM images to PPM/PGM, PNG, TIFF or BMP
--dcmquant: Convert DICOM color images to palette color
--dcmscale: Scale DICOM images
举例:
--载入一幅DICOM单帧图像(单色或彩色),并显示其像素数据。
#include "diregist.h" /* required to support color images */
/* ... */
DicomImage *image = new DicomImage("test.dcm");
if (image != NULL)
{
if (image->getStatus() == EIS_Normal)
{
Uint8 *pixelData = (Uint8 *)(image->getOutputData(8 /* bits per sample */));
if (pixelData != NULL)
{
/* do something useful with the pixel data */
}
} else
cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << endl;
}
delete image;