本文整理汇总了C++中DcmFileFormat::getAndRemoveDataset方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmFileFormat::getAndRemoveDataset方法的具体用法?C++ DcmFileFormat::getAndRemoveDataset怎么用?C++ DcmFileFormat::getAndRemoveDataset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DcmFileFormat
的用法示例。
在下文中一共展示了DcmFileFormat::getAndRemoveDataset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitializeFromFile
void ctkDICOMDataset::InitializeFromFile(const QString& filename,
const E_TransferSyntax readXfer,
const E_GrpLenEncoding groupLength,
const Uint32 maxReadLength,
const E_FileReadMode readMode)
{
DcmDataset *dataset;
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile(filename.toAscii().data(), readXfer, groupLength, maxReadLength, readMode);
dataset = fileformat.getAndRemoveDataset();
if (!status.good())
{
qDebug() << "Could not load " << filename << "\nDCMTK says: " << status.text();
delete dataset;
return;
}
InitializeFromDataset(dataset, true);
}
示例2: Write
void DICOMSegmentationIO::Write()
{
ValidateOutputLocation();
mitk::LocaleSwitch localeSwitch("C");
LocalFile localFile(this);
const std::string path = localFile.GetFileName();
auto input = dynamic_cast<const LabelSetImage *>(this->GetInput());
if (input == nullptr)
mitkThrow() << "Cannot write non-image data";
// Get DICOM information from referenced image
vector<DcmDataset *> dcmDatasets;
DcmFileFormat *readFileFormat = new DcmFileFormat();
try
{
// TODO: Generate dcmdataset witk DICOM tags from property list; ATM the source are the filepaths from the
// property list
mitk::StringLookupTableProperty::Pointer filesProp =
dynamic_cast<mitk::StringLookupTableProperty *>(input->GetProperty("files").GetPointer());
if (filesProp.IsNull())
{
mitkThrow() << "No property with dicom file path.";
return;
}
StringLookupTable filesLut = filesProp->GetValue();
const StringLookupTable::LookupTableType &lookUpTableMap = filesLut.GetLookupTable();
for (auto it : lookUpTableMap)
{
const char *fileName = (it.second).c_str();
if (readFileFormat->loadFile(fileName, EXS_Unknown).good())
dcmDatasets.push_back(readFileFormat->getAndRemoveDataset());
}
}
catch (const std::exception &e)
{
MITK_ERROR << "An error occurred while getting the dicom informations: " << e.what() << endl;
return;
}
// Iterate over all layers. For each a dcm file will be generated
for (unsigned int layer = 0; layer < input->GetNumberOfLayers(); ++layer)
{
vector<itkInternalImageType::Pointer> segmentations;
try
{
// Cast mitk layer image to itk
ImageToItk<itkInputImageType>::Pointer imageToItkFilter = ImageToItk<itkInputImageType>::New();
// BUG: It must be the layer image, but there are some errors with it (dcmqi: generate the dcmSeg "No frame data
// available") --> input->GetLayerImage(layer)
imageToItkFilter->SetInput(input);
imageToItkFilter->Update();
// Cast from original itk type to dcmqi input itk image type
typedef itk::CastImageFilter<itkInputImageType, itkInternalImageType> castItkImageFilterType;
castItkImageFilterType::Pointer castFilter = castItkImageFilterType::New();
castFilter->SetInput(imageToItkFilter->GetOutput());
castFilter->Update();
itkInternalImageType::Pointer itkLabelImage = castFilter->GetOutput();
itkLabelImage->DisconnectPipeline();
// Iterate over all labels. For each a segmentation image will be created
const LabelSet *labelSet = input->GetLabelSet(layer);
for (auto itLabel = labelSet->IteratorConstBegin(); itLabel != labelSet->IteratorConstEnd(); ++itLabel)
{
// Thresold over the image with the given label value
itk::ThresholdImageFilter<itkInternalImageType>::Pointer thresholdFilter =
itk::ThresholdImageFilter<itkInternalImageType>::New();
thresholdFilter->SetInput(itkLabelImage);
thresholdFilter->ThresholdOutside(itLabel->first, itLabel->first);
thresholdFilter->SetOutsideValue(0);
thresholdFilter->Update();
itkInternalImageType::Pointer segmentImage = thresholdFilter->GetOutput();
segmentImage->DisconnectPipeline();
segmentations.push_back(segmentImage);
}
}
catch (const itk::ExceptionObject &e)
{
MITK_ERROR << e.GetDescription() << endl;
return;
}
// Create segmentation meta information
const std::string &tmpMetaInfoFile = this->CreateMetaDataJsonFile(layer);
MITK_INFO << "Writing image: " << path << std::endl;
try
{
// Convert itk segmentation images to dicom image
dcmqi::ImageSEGConverter *converter = new dcmqi::ImageSEGConverter();
DcmDataset *result = converter->itkimage2dcmSegmentation(dcmDatasets, segmentations, tmpMetaInfoFile);
//.........这里部分代码省略.........