本文整理汇总了C++中DcmFileFormat::loadAllDataIntoMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmFileFormat::loadAllDataIntoMemory方法的具体用法?C++ DcmFileFormat::loadAllDataIntoMemory怎么用?C++ DcmFileFormat::loadAllDataIntoMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DcmFileFormat
的用法示例。
在下文中一共展示了DcmFileFormat::loadAllDataIntoMemory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_dcmFiles
// Load our vtkImageData object from a list of DICOM image filenames...
// http://www.vtk.org/pipermail/vtkusers/2007-August/042635.html
void vtkDicom::load_dcmFiles(QStringList dcm_fileList) {
DcmFileFormat dcm;
std::string imgFname;
std::cout << "vtkdicom: Files/Images(?): " << dcm_fileList.size() << "\n";
for (int sei = 0; sei < dcm_fileList.size(); ++sei) {
imgFname = dcm_fileList.at(sei).toLocal8Bit().constData();
OFCondition status = dcm.loadFile(imgFname.c_str());
if (!status.good()) {
std::cout << " vtkdicom: Error: cannot read file (" << status.text() << ")" << "\n";
return;
}
if (sei == 0) {
OFString acquisitionNumber, instanceNumber, imagePositionPatient, patientsName;
DcmDataset *dcmDs = dcm.getDataset();
dcmDs->findAndGetOFStringArray(DCM_ImagePositionPatient, imagePositionPatient);
dcmDs->findAndGetOFString(DCM_AcquisitionNumber, acquisitionNumber);
dcmDs->findAndGetOFString(DCM_InstanceNumber, instanceNumber);
dcmDs->findAndGetOFString(DCM_PatientName, patientsName);
std::cout << "vtkdicom: I#, IPP: " << instanceNumber << " - " << imagePositionPatient << "\n";
}
dcm.loadAllDataIntoMemory();
const unsigned short* p = NULL;
dcm.getDataset()->findAndGetUint16Array(DCM_PixelData, p);
}
}
示例2: dumpDicomFile
void vtkDicom::dumpDicomFile(std::string imgFname)
{
DcmFileFormat dfile;
OFCondition status = dfile.loadFile(imgFname.c_str());
if (status.good()) {
OFString acquisitionNumber, instanceNumber, imagePositionPatient, patientsName;
dfile.loadAllDataIntoMemory();
DcmDataset *dcmDs = dfile.getDataset();
dcmDs->findAndGetOFStringArray(DCM_ImagePositionPatient, imagePositionPatient);
dcmDs->findAndGetOFString(DCM_AcquisitionNumber, acquisitionNumber);
dcmDs->findAndGetOFString(DCM_InstanceNumber, instanceNumber);
dcmDs->findAndGetOFString(DCM_PatientName, patientsName);
std::cout << " " << instanceNumber << " - " << imagePositionPatient << "\n";
} else {
std::cout << " Error: cannot read file (" << status.text() << ")" << "\n";
}
}
示例3: retrieve
//.........这里部分代码省略.........
{
logger.error ( "Error initializing the network" );
return false;
}
logger.debug ( "Negotiating Association" );
if ( !scu.negotiateAssociation().good() )
{
logger.error ( "Error negotiating association" );
return false;;
}
logger.debug ( "Setting Parameters" );
// Clear the query
unsigned long elements = this->parameters->card();
// Clean it out
for ( unsigned long i = 0; i < elements; i++ )
{
this->parameters->remove ( 0ul );
}
if ( retriveType == RetrieveSeries )
{
this->parameters->putAndInsertString ( DCM_QueryRetrieveLevel, "SERIES" );
this->parameters->putAndInsertString ( DCM_SeriesInstanceUID, UID.toStdString().c_str() );
}
else
{
this->parameters->putAndInsertString ( DCM_QueryRetrieveLevel, "STUDY" );
this->parameters->putAndInsertString ( DCM_StudyInstanceUID, UID.toStdString().c_str() );
}
logger.debug ( "Sending Move Request" );
MOVEResponses *responses = new MOVEResponses();
OFCondition status = scu.sendMOVERequest ( 0, this->parameters, responses );
if (!status.good())
{
logger.error ( "MOVE Request failed: " + QString ( status.text() ) );
return false;
}
logger.debug ( "Find succeded" );
logger.debug ( "Making Output Directory" );
QDir directory = QDir( RetrieveDatabase->databaseDirectory() );
if ( responses->begin() == responses->end() )
{
logger.error ( "No responses!" );
throw std::runtime_error( std::string("No responses!") );
}
// Write the responses out to disk
for ( OFListIterator(FINDResponse*) it = responses->begin(); it != responses->end(); it++ )
{
DcmDataset *dataset = (*it)->m_dataset;
if ( dataset != NULL )
{
logger.debug ( "Got a valid dataset" );
// Save in correct directory
E_TransferSyntax output_transfersyntax = dataset->getOriginalXfer();
dataset->chooseRepresentation( output_transfersyntax, NULL );
if ( !dataset->canWriteXfer( output_transfersyntax ) )
{
// Pick EXS_LittleEndianExplicit as our default
output_transfersyntax = EXS_LittleEndianExplicit;
}
DcmXfer opt_oxferSyn( output_transfersyntax );
if ( !dataset->chooseRepresentation( opt_oxferSyn.getXfer(), NULL ).bad() )
{
DcmFileFormat* fileformat = new DcmFileFormat ( dataset );
// Follow dcmdjpeg example
fileformat->loadAllDataIntoMemory();
OFString SOPInstanceUID;
dataset->findAndGetOFString ( DCM_SOPInstanceUID, SOPInstanceUID );
QFileInfo fi ( directory, QString ( SOPInstanceUID.c_str() ) );
logger.debug ( "Saving file: " + fi.absoluteFilePath() );
status = fileformat->saveFile ( fi.absoluteFilePath().toStdString().c_str(), opt_oxferSyn.getXfer() );
if ( !status.good() )
{
logger.error ( "Error saving file: " + fi.absoluteFilePath() + " Error is " + status.text() );
}
RetrieveDatabase->insert( dataset, true );
delete fileformat;
}
}
}
delete responses;
//if ( !scu.dropNetwork().good() )
//{
//logger.error ( "Error dropping the network" );
//return false;
//}
return true;
}
示例4: dcm2img
void dcm2img(boost::filesystem::path filename, int clientWidth, int clientHeight, wxImage &image)
{
OFLog::configure(OFLogger::OFF_LOG_LEVEL);
unsigned char *source = NULL;
try
{
DcmFileFormat dfile;
if (dfile.loadFile(filename.c_str(), EXS_Unknown, EGL_withoutGL).bad())
throw std::runtime_error("");
if(dfile.loadAllDataIntoMemory().bad())
throw std::runtime_error("");
// uncompress
DicomImage di(&dfile, EXS_Unknown);
if(di.getStatus() != EIS_Normal)
throw std::runtime_error("");
di.getFirstFrame();
di.showAllOverlays();
if (di.isMonochrome())
{
if(di.getWindowCount())
di.setWindow(0);
else
di.setHistogramWindow();
}
// don't use di.createScaledImage, it is broken!!
unsigned int width = di.getWidth();
unsigned int height = di.getHeight();
if(!image.Create(width, height, true))
throw std::runtime_error("");
source = new unsigned char[width * height * 4];
di.createWindowsDIB((void * &)source, width * height * 4, 0, 32);
wxImagePixelData data(image);
wxImagePixelData::Iterator p(data);
for(int j = 0; j < height; j++)
{
for(int i = 0; i < width; i++)
{
p.MoveTo(data, i, j);
p.Red() = source[(width * j + i) * 4 + 2];
p.Green() = source[(width * j + i) * 4 + 1];
p.Blue() = source[(width * j + i) * 4];
}
}
// scale
float widthFactor = (float) clientWidth / (float) width;
float heightFactor = (float) clientHeight / (float) height;
float scaleFactor = 0;
if (widthFactor < heightFactor)
scaleFactor = widthFactor;
else
scaleFactor = heightFactor;
int scaledWidth = width * scaleFactor;
int scaledHeight = height * scaleFactor;
image.Rescale(scaledWidth, scaledHeight);
}
catch(...)
{
}
if(source != NULL)
delete source;
}