当前位置: 首页>>代码示例>>C++>>正文


C++ DcmDataset::findAndGetUint8Array方法代码示例

本文整理汇总了C++中DcmDataset::findAndGetUint8Array方法的典型用法代码示例。如果您正苦于以下问题:C++ DcmDataset::findAndGetUint8Array方法的具体用法?C++ DcmDataset::findAndGetUint8Array怎么用?C++ DcmDataset::findAndGetUint8Array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DcmDataset的用法示例。


在下文中一共展示了DcmDataset::findAndGetUint8Array方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

bool IODicom<T>::Read(PGCore::BaseDataObject *oDataObject, const IOParams &iParams,
                      PGCore::BaseDataObject *oMetaDataObject/* = 0*/)
{
    // read meta data first
    if (!oMetaDataObject) {
        LOG0("IO/IODicom::Read: metadata object null");
        return false;
    }

    if (iParams.SourceType()!=kPgIOSourceTypeFile)
    {
        LOG0("IO/IODicom::Read: Expecting single file path.");
        return false;
    }

    if (!ReadMetaData(oMetaDataObject, iParams))
    {
        LOG0("IO/IODicom::Read: ReadMetaData failed.");
        return false;
    }

    if (!oDataObject)
    {
        LOG0("IO/IODicom::Read: Invalid input image.");
        return false;
    }

    // cast to image type here
    PGCore::Image<T> *oImage = (static_cast<PGCore::Image < T > *>(oDataObject));
    if (!oImage)
    {
        LOG0("IO/IODicom::Read: Invalid input image.");
        return false;
    }

    PGCore::MetaData<T> *oMetaData = (static_cast<PGCore::MetaData< T > *>(oMetaDataObject));
    if (!oMetaData)
    {
        LOG0("IO/IOBase::Read: Invalid output container for metadata.");
        return false;
    }

    int frameCount = oMetaData->GetFrameCount();
    int frameIndex = 0;

    if (frameCount>1)
    {
        frameIndex = iParams.GetActiveFrameIndex();
        if (frameIndex<0 || frameIndex>(frameCount-1))
        {
            LOG2("IO/IODicom::Read: Invalid frame index: %d/%d", frameIndex, frameCount);
            return false;
        }
    }


    //calculate the full size of the scalars
    const PGMath::Vector3D<int>& oSize = oMetaData->GetSize();
    long ix=oSize.Y(), iy=oSize.X();
    oImage->SetDimensions(ix, iy);

    T* oBuf = oImage->GetBuffer();
    if (!oBuf)
    {
        LOG0("IO/IODicom::Read: Invalid image buffer.");
        return false;
    }

    bool needConversion = false;
    int nBitsPerPixel = oMetaData->GetNumberOfBits();
    if (nBitsPerPixel!=8*sizeof(T))
    {
        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);
//.........这里部分代码省略.........
开发者ID:yangguang-ecnu,项目名称:smisdk,代码行数:101,代码来源:IODicom.hpp


注:本文中的DcmDataset::findAndGetUint8Array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。