本文整理汇总了C++中DcmDataset::findAndGetUint16Array方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmDataset::findAndGetUint16Array方法的具体用法?C++ DcmDataset::findAndGetUint16Array怎么用?C++ DcmDataset::findAndGetUint16Array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DcmDataset
的用法示例。
在下文中一共展示了DcmDataset::findAndGetUint16Array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
//.........这里部分代码省略.........
{
LOG2("IO/IODicom::Read:Warning: Pixel type mismatch. Need %d bits per pixel, but reporting %d.", nBitsPerPixel, 8*sizeof(T));
needConversion = true;
//return false;
}
int oByteCount = (nBitsPerPixel/8) * ix * iy;
long offset = frameIndex*ix*iy;
unsigned char *iBuf=0;
#ifdef _PG_GDDCM_
#else
// read pixel data
//DcmFileFormat fileformat;
DcmDataset *dataset = m_fileformat.getDataset();
if (!dataset)
{
LOG0("IO/IODicom::Read: Cannot fetch pixel data");
return false;
}
switch (nBitsPerPixel)
{
case 8:
dataset->findAndGetUint8Array(DCM_PixelData, (const Uint8 *&) iBuf);
if (frameCount>1)
{
iBuf = (unsigned char *)((Uint8 *)iBuf + offset);
}
break;
case 16:
dataset->findAndGetUint16Array(DCM_PixelData, (const Uint16 *&) iBuf);
if (frameCount>1)
{
iBuf = (unsigned char *)((Uint16 *)iBuf + offset);
}
break;
default:
LOG0("IO/IODicom::Read: failed to fetch image buffer.");
return false;
}
#endif
if (iBuf==0)
{
LOG0("IO/IODicom::Read: Invalid image buffer.");
return false;
}
// we have to copy the data into the buffer already allocated
if (!needConversion)
{
memcpy(oBuf, iBuf, oByteCount);
} else
{
// first create a local image
PGCore::Image<unsigned char> ucharImage;
PGCore::Image<short> shortImage;
unsigned char* localBuf = 0;
switch (nBitsPerPixel)
{
case 8:
示例2: DcmFileFormat
bool Dicom::DicomReader::OpenDicoms(const std::list<std::string>& dcms)
{
if (m_pImageData)
{
//已经打开了数据
return false;
}
std::map<int,DcmFileFormat*> mapDcms;
int iMaxLayer = -1;
int iMinLayer = INT_MAX;
{
//获取图像数据
std::list<std::string>::const_iterator iter = dcms.begin();
while (iter != dcms.end())
{
DcmFileFormat* pDcmFile = new DcmFileFormat();
OFCondition cond = pDcmFile->loadFile(iter->c_str());
if (cond.bad())
{
delete pDcmFile;
++iter;
continue;
}
DcmDataset* pDataset = pDcmFile->getDataset();
Uint16 iC = 0, iR = 0, iB = 0;
pDataset->findAndGetUint16(DCM_Columns, iC);
pDataset->findAndGetUint16(DCM_Rows, iR);
pDataset->findAndGetUint16(DCM_BitsAllocated, iB);
if (mapDcms.size()<1)
{
m_iColumns = iC;
m_iRows = iR;
m_iBits = iB;
}
if (iC != m_iColumns || iR != m_iRows || iB != m_iBits)
{
delete pDcmFile;
++iter;
continue;
}
Sint32 iL = -1;
pDataset->findAndGetSint32(DCM_InstanceNumber, iL);
if (iL>-1 && mapDcms.find(iL) == mapDcms.end())
{
mapDcms[iL] = pDcmFile;
if (iL > iMaxLayer)
iMaxLayer = iL;
if (iL < iMinLayer)
iMinLayer = iL;
}
else
{
delete pDcmFile;
}
++iter;
}
if (m_iBits != 16)
return false;
}
//总层数
m_iLayers = iMaxLayer-iMinLayer+1;
m_pImageData = new Image::ImageData<short>(m_iRows, m_iColumns, m_iLayers);
Image::ImageData<short>* pImageShort = reinterpret_cast<Image::ImageData<short>*>(m_pImageData);
char* pDataPtr = m_pImageData->GetDataPtr();
{
//设置图像数据
std::map<int, DcmFileFormat*>::iterator iter = mapDcms.begin();
while (iter != mapDcms.end())
{
DcmFileFormat* pDcmFile = iter->second;
DcmDataset* pDataSet = pDcmFile->getDataset();
{
const Uint16* pSrcData = NULL;
unsigned long iCount = 0;
pDataSet->findAndGetUint16Array(DCM_PixelData, pSrcData, &iCount);
if (iCount == pImageShort->GetX()*pImageShort->GetY())
{
memcpy(pDataPtr+(iCount*2*(iter->first-iMinLayer)), pSrcData, iCount * 2);
}
else
{
assert("Read dicom error!");
}
}
delete pDcmFile;
++iter;
//.........这里部分代码省略.........