本文整理汇总了C++中DcmDataset::putAndInsertString方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmDataset::putAndInsertString方法的具体用法?C++ DcmDataset::putAndInsertString怎么用?C++ DcmDataset::putAndInsertString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DcmDataset
的用法示例。
在下文中一共展示了DcmDataset::putAndInsertString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cgetDcm
bool DcmSend::cgetDcm()
{
OFVector<RetrieveResponse*> findResponses;
DcmDataset req;
// req.putAndInsertString(DCM_PatientName,"Nurmukhametov");
// req.putAndInsertString(DCM_SOPInstanceUID,"1.3.12.2.1107.5.4.5.55301.30000013021404234482800000106.512");
req.putAndInsertString(DCM_SeriesInstanceUID,"1.3.12.2.1107.5.2.13.20561.30000005042216091690600002608");
req.putAndInsertString(DCM_QueryRetrieveLevel,"SERIES");
// req.putAndInsertString(DCM_SOPClassUID,"1.2.840.10008.5.1.4.1.1.4");
// req.putAndInsertString(DCM_StudyInstanceUID,"1.2.840.113745.101000.1008000.38446.6272.7138759");
Sender.setStorageMode(DCMSCU_STORAGE_DISK);
Sender.setStorageDir("/tmp/dcmstorage");
// req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY");
// req.putAndInsertOFStringArray(DCM_StudyInstanceUID, "");
T_ASC_PresentationContextID presID = findUncompressedPC(UID_GETStudyRootQueryRetrieveInformationModel, Sender);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return false;
}
result=Sender.sendCGETRequest(presID,&req,&findResponses);
if (result.bad())
return false;
return true;
}
示例2: 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;
}