标签:语法 vector tran for logger nta const 处理 main
Dicom 多帧影像一般都比较大,全部读取的话对内存的要求很高,而且效率很低,所以在这种情况下需要一个单帧提取的方式。这里分别介绍DCMTK和GDCM的单帧提取的方式:
DCMTK:
#include "dcmtk/config/osconfig.h" #include "dcmtk/dcmimgle/dcmimage.h" int main(int argc, char *argv[]) { OFLog::configure(OFLogger::INFO_LOG_LEVEL); DicomImage *image = new DicomImage("mf_image.dcm", CIF_UsePartialAccessToPixelData, 0, 10 /* fcount */); if (image->getStatus() == EIS_Normal) { do { DCMIMGLE_INFO("processing frame " << image->getFirstFrame() + 1 << " to " << image->getFirstFrame() + image->getFrameCount()); } while (image->processNextFrames()); } delete image; return 0; }
GDCM:
gdcm::ImageRegionReader reader; reader.SetFileName(fileName); std::vector<unsigned int> dims = gdcm::ImageHelper::GetDimensionsValue(reader.GetFile()); gdcm::BoxRegion box; box.SetDomain(0, dims[0] - 1, 0, dims[1] - 1, i, i); reader.SetRegion(box); size_t bufferLength = reader.ComputeBufferLength(); char* buffer = new char[bufferLength]; memset(buffer, 0x0, bufferLength); if (!reader.ReadIntoBuffer(buffer, bufferLength)) { std::cout << "读取失败" << std::endl; return 0; }
GDCM 处理的时候有个问题需要注意,用ImageRegionReader读取出来后,再去调用 reader.GetImage().GetTransferSyntax() 去获取文件语法,会发现该语法和原始Dicom文件的语法不一致,所以如果需要获取文件语法,需要以下方法进行获取:
const FileMetaInformation &header = reader.GetFile().GetHeader(); const TransferSyntax &ts = header.GetDataSetTransferSyntax();
标签:语法 vector tran for logger nta const 处理 main
原文地址:https://www.cnblogs.com/Farmer-D/p/13819544.html