⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dimoopxt.h

📁 转化为DIB位图再显示出来的dicom文件C++代码
💻 H
📖 第 1 页 / 共 5 页
字号:
                                    value2 = pcnt - 1;                                // last LUT index                                else                                    value2 = OFstatic_cast(Uint32, (value - leftBorder) * gradient1);                                *(q++) = OFstatic_cast(T3, OFstatic_cast(double, low) + OFstatic_cast(double, plut->getValue(value2)) * gradient2);                            }                        }                    }                } else {                                                              // has no presentation LUT                    createDisplayLUT(dlut, disp, bitsof(T1));                    if (initOptimizationLUT(lut, ocnt))                    {                                                                 // use LUT for optimization                        q = lut;                        if (dlut != NULL)                                             // perform display transformation                        {                            const double maxvalue = OFstatic_cast(double, dlut->getCount() - 1);                            const double offset = (low > high) ? maxvalue : 0;                            const double gradient = (width_1 == 0) ? 0 : ((low > high) ? (-maxvalue / width_1) : (maxvalue / width_1));                            for (i = 0; i < ocnt; ++i)                                // calculating LUT entries                            {                                value = OFstatic_cast(double, i) + absmin - leftBorder;                                if (value < 0)                                               // left border                                    value = 0;                                else if (value > width_1)                                    // right border                                    value = width_1;                                *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, offset + value * gradient)));  // calculate value                            }                        } else {                                                       // don't use display: invalid or absent                            const double offset = (width_1 == 0) ? 0 : (high - ((center - 0.5) / width_1 + 0.5) * outrange);                            const double gradient = (width_1 == 0) ? 0 : outrange / width_1;                            for (i = 0; i < ocnt; ++i)                                 // calculating LUT entries                            {                                value = OFstatic_cast(double, i) + absmin;                                if (value <= leftBorder)                                    *(q++) = low;                                            // black/white                                else if (value > rightBorder)                                    *(q++) = high;                                           // white/black                                else                                    *(q++) = OFstatic_cast(T3, offset + value * gradient);   // gray value                            }                        }                        const T3 *lut0 = lut - OFstatic_cast(T2, absmin);             // points to 'zero' entry                        q = Data;                        for (i = Count; i != 0; --i)                                  // apply LUT                            *(q++) = *(lut0 + (*(p++)));                    }                    if (lut == NULL)                                                  // use "normal" transformation                    {                        if (dlut != NULL)                                             // perform display transformation                        {                            const double maxvalue = OFstatic_cast(double, dlut->getCount() - 1);                            const double offset = (low > high) ? maxvalue : 0;                            const double gradient = (width_1 == 0) ? 0 : ((low > high) ? (-maxvalue / width_1) : (maxvalue / width_1));                            for (i = Count; i != 0; --i)                              // calculating LUT entries                            {                                value = OFstatic_cast(double, *(p++)) - leftBorder;                                if (value < 0)                                               // left border                                    value = 0;                                else if (value > width_1)                                    // right border                                    value = width_1;                                *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, offset + value * gradient)));  // calculate value                            }                        } else {                                                      // don't use display: invalid or absent                            const double offset = (width_1 == 0) ? 0 : (high - ((center - 0.5) / width_1 + 0.5) * outrange);                            const double gradient = (width_1 == 0) ? 0 : outrange / width_1;                            for (i = Count; i != 0; --i)                            {                                value = OFstatic_cast(double, *(p++));                                if (value <= leftBorder)                                    *(q++) = low;                                            // black/white                                else if (value > rightBorder)                                    *(q++) = high;                                           // white/black                                else                                    *(q++) = OFstatic_cast(T3, offset + value * gradient);   // gray value                            }                        }                    }                }                delete[] lut;                if (Count < FrameSize)                    OFBitmanipTemplate<T3>::zeroMem(Data + Count, FrameSize - Count);        // set remaining pixels of frame to zero            }        } else            Data = NULL;    }    /** apply the currently active overlay planes to the output data     *     ** @param  overlays  array of overlay management objects     *  @param  disp      display function (optional, maybe NULL)     *  @param  columns   image's width (in pixels)     *  @param  rows      image's height (in pixels)     *  @param  frame     number of frame to be rendered     */    void overlay(DiOverlay *overlays[2],                 DiDisplayFunction *disp,                 const Uint16 columns,                 const Uint16 rows,                 const unsigned long frame)    {        if ((Data != NULL) && (overlays != NULL))        {            for (unsigned int j = 0; j < 2; ++j)            {                if (overlays[j] != NULL)                {                    const signed long left_pos = overlays[j]->getLeft();                    const signed long top_pos = overlays[j]->getTop();                    register DiOverlayPlane *plane;                    for (unsigned int i = 0; i < overlays[j]->getCount(); ++i)                    {                        plane = overlays[j]->getPlane(i);                        if ((plane != NULL) && plane->isVisible() && plane->reset(frame))                        {                            register T3 *q;                            register Uint16 x;                            register Uint16 y;                            const Uint16 xmin = (plane->getLeft(left_pos) > 0) ? plane->getLeft(left_pos) : 0;                            const Uint16 ymin = (plane->getTop(top_pos) > 0) ? plane->getTop(top_pos) : 0;                            const Uint16 xmax = (plane->getRight(left_pos) < columns) ? plane->getRight(left_pos) : columns;                            const Uint16 ymax = (plane->getBottom(top_pos) < rows) ? plane->getBottom(top_pos) : rows;                            const T3 maxvalue = OFstatic_cast(T3, DicomImageClass::maxval(bitsof(T3)));                            switch (plane->getMode())                            {                                case EMO_Replace:                                {                                    const T3 fore = OFstatic_cast(T3, plane->getForeground() * maxvalue);                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (plane->getNextBit())                                                *q = fore;                                        }                                    }                                    break;                                }                                case EMO_ThresholdReplace:                                {                                    const T3 fore = OFstatic_cast(T3, plane->getForeground() * maxvalue);                                    const T3 thresh = OFstatic_cast(T3, plane->getThreshold() * maxvalue);                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (plane->getNextBit())                                                *q = (*q <= thresh) ? fore : 1;                                        }                                    }                                    break;                                }                                case EMO_Complement:                                {                                    const T3 thresh = OFstatic_cast(T3, DicomImageClass::maxval(bitsof(T3) / 2));                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (plane->getNextBit())                                                *q = (*q <= thresh) ? maxvalue : 0;                                        }                                    }                                    break;                                }                                case EMO_InvertBitmap:                                {                                    const T3 fore = OFstatic_cast(T3, plane->getForeground() * maxvalue);                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (!plane->getNextBit())                                                *q = fore;                                        }                                    }                                    break;                                }                                case EMO_RegionOfInterest:                                {                                    const int dim = bitsof(T3) / 2;                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (!plane->getNextBit())                                                *q = *q >> dim;                                        }                                    }                                    break;                                }                                case EMO_BitmapShutter:                                {                                    register T3 fore = OFstatic_cast(T3, OFstatic_cast(double, maxvalue) * OFstatic_cast(double, plane->getPValue()) / OFstatic_cast(double, DicomImageClass::maxval(WIDTH_OF_PVALUES)));                                    if ((disp != NULL) && (disp->isValid()))                                    {                                        const DiDisplayLUT *dlut = disp->getLookupTable(WIDTH_OF_PVALUES);                                        if ((dlut != NULL) && (dlut->isValid()))                                            fore = OFstatic_cast(T3, dlut->getValue(plane->getPValue()));                                    }                                    for (y = ymin; y < ymax; ++y)                                    {                                        plane->setStart(OFstatic_cast(Uint16, left_pos + xmin), OFstatic_cast(Uint16, top_pos + y));                                        q = Data + OFstatic_cast(unsigned long, y) * OFstatic_cast(unsigned long, columns) + OFstatic_cast(unsigned long, xmin);                                        for (x = xmin; x < xmax; ++x, ++q)                                        {                                            if (plane->getNextBit())                                                *q = fore;                                        }                                    }                                    break;                                }                                default: /* e.g. EMO_Default */                                    if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Warnings))                                    {                                        ofConsole.lockCerr() << "WARNING: unhandled overlay mode (" << OFstatic_cast(int, pl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -