本文整理汇总了C++中DcmDataset::putAndInsertUint16方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmDataset::putAndInsertUint16方法的具体用法?C++ DcmDataset::putAndInsertUint16怎么用?C++ DcmDataset::putAndInsertUint16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DcmDataset
的用法示例。
在下文中一共展示了DcmDataset::putAndInsertUint16方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fixture
Fixture()
{
OFCondition condition;
condition = dataset.putAndInsertOFStringArray(DCM_PatientID, "DJ123");
if(condition.bad())
{
throw odil::dcmtk::Exception(condition);
}
condition = dataset.putAndInsertUint16(DCM_MessageID, 1234);
if(condition.bad())
{
throw odil::dcmtk::Exception(condition);
}
}
示例2: open_dicomdir_series_result
static void open_dicomdir_series_result(const Glib::ustring &dicomdir, DcmDirectoryRecord *patRec, DcmDirectoryRecord *studyRec, const sigc::slot< void, const Glib::RefPtr< ImagePool::Series >& >& resultslot) {
DcmDirectoryRecord *seriesRec;
DcmDirectoryRecord *sopRec;
assert(studyRec->getRecordType()==ERT_Study);
seriesRec = studyRec->nextSub(NULL);
while ( seriesRec ) {
DcmDataset series;
DcmElement *el;
if ( seriesRec->findAndCopyElement(DCM_SpecificCharacterSet, el) == ECC_Normal )
series.insert(el);
if ( seriesRec->findAndCopyElement(DCM_SeriesDescription, el) == ECC_Normal )
series.insert(el);
if ( seriesRec->findAndCopyElement(DCM_SeriesInstanceUID, el) == ECC_Normal )
series.insert(el);
if ( seriesRec->findAndCopyElement(DCM_Modality, el) == ECC_Normal )
series.insert(el);
if ( seriesRec->findAndCopyElement(DCM_SeriesDate, el) == ECC_Normal )
series.insert(el);
if ( seriesRec->findAndCopyElement(DCM_SeriesTime, el) == ECC_Normal )
series.insert(el);
if ( studyRec->findAndCopyElement(DCM_StudyDescription, el) == ECC_Normal )
series.insert(el);
if ( studyRec->findAndCopyElement(DCM_StationName, el) == ECC_Normal )
series.insert(el);
// Count Related SOP Instances
int nSop=0;
sopRec = seriesRec->nextSub(NULL);
while (sopRec) {
nSop++;
sopRec = seriesRec->nextSub(sopRec);
}
series.putAndInsertUint16(DCM_NumberOfSeriesRelatedInstances, nSop);
resultslot(create_query_series(&series));
seriesRec = studyRec->nextSub(seriesRec);
}
}
示例3: gendicom
int gendicom(const char* file_name, const std::vector<float> &data,
unsigned int rows, unsigned int cols)
{
char uid[100];
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
OFCondition result = EC_Normal;
if (result.good()) result = dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
//if (result.good()) result = dataset->putAndInsertString(DCM_MediaStorageSOPClassUID, UID_SecondaryCaptureImageStorage); //same as SOP
if (result.good()) result = dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
//if (result.good()) result = dataset->putAndInsertString(DCM_MediaStorageSOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
if (result.good()) result = dataset->putAndInsertString(DCM_SeriesInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
if (result.good()) result = dataset->putAndInsertString(DCM_StudyInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
//if (result.good()) result = dataset->putAndInsertString(DCM_TransferSyntaxUID, UID_LittleEndianExplicitTransferSyntax);
//if (result.good()) result = dataset->putAndInsertUint16(DCM_FileMetaInformationVersion, 1);
if (result.good()) result = dataset->putAndInsertString(DCM_ImageType, "DERIVED");
if (result.good()) result = dataset->putAndInsertString(DCM_Modality, "MR");
if (result.good()) result = dataset->putAndInsertString(DCM_ConversionType, "WSD");
if (result.good()) result = dataset->putAndInsertString(DCM_DerivationDescription, "IRGN Processed MR Reconstruction");
if (result.good()) result = dataset->putAndInsertString(DCM_SecondaryCaptureDeviceManufacturer, "IMT TUGRAZ");
if (result.good()) result = dataset->putAndInsertString(DCM_SecondaryCaptureDeviceManufacturerModelName, "IMT Cuda Workstation");
if (result.good()) result = dataset->putAndInsertString(DCM_PatientName, "Doe^John");
// set instance creation date and time
OFString s;
if (result.good()) result = DcmDate::getCurrentDate(s);
if (result.good()) result = dataset->putAndInsertOFStringArray(DCM_InstanceCreationDate, s);
if (result.good()) result = DcmTime::getCurrentTime(s);
if (result.good()) result = dataset->putAndInsertOFStringArray(DCM_InstanceCreationTime, s);
//--- Write image-data ---
std::vector<Uint16> uint16_data;
float val=0;
float min_val;
float max_val = *std::max_element(data.begin(),data.end());
for(unsigned int i=0; i<data.size(); ++i)
{
val = (data[i]/max_val)*65535;
uint16_data.push_back(Uint16(val));
}
max_val = *std::max_element(uint16_data.begin(),uint16_data.end());
min_val = *std::min_element(uint16_data.begin(),uint16_data.end());
std::cout<<"\n max-val: "<<max_val;
std::cout<<"\n min-val: "<<min_val;
unsigned bits=16;
Uint16 bitsAllocated=((bits-1)/8+1)*8;
Uint16 bitsStored=bits;
Uint16 highBit=bits-1;
if (result.good()) result = dataset->putAndInsertUint16(DCM_BitsAllocated, bitsAllocated);
if (result.good()) result = dataset->putAndInsertUint16(DCM_BitsStored, bitsStored);
if (result.good()) result = dataset->putAndInsertUint16(DCM_HighBit, highBit);
if (result.good()) result = dataset->putAndInsertUint16(DCM_Rows, rows);
if (result.good()) result = dataset->putAndInsertUint16(DCM_Columns, cols);
if (result.good()) result = dataset->putAndInsertUint16(DCM_PixelRepresentation, 0); // 1 signed, 0 unsigned
if (result.good()) result = dataset->putAndInsertOFStringArray(DCM_PhotometricInterpretation, "MONOCHROME2");
if (result.good()) result = dataset->putAndInsertUint16(DCM_SamplesPerPixel, 1);
if (result.good()) result = dataset->putAndInsertUint16(DCM_SmallestImagePixelValue, min_val);
if (result.good()) result = dataset->putAndInsertUint16(DCM_LargestImagePixelValue, max_val);
Uint8* pixelData = (Uint8*)&uint16_data[0];
Uint32 pixelLength;
pixelLength = uint16_data.size()*2; //number of elements in vector * 2bytes (for Uint16)
dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);
OFCondition status = fileformat.saveFile(file_name, EXS_LittleEndianExplicit);
if (result.bad())
std::cerr << "Error: cannot write DICOM file (" << result.text() << ")" << std::endl;
if (status.bad())
std::cerr << "Error: cannot write DICOM file (" << status.text() << ")" << std::endl;
return 0;
}