📄 dimoopxt.h
字号:
{ const Uint16 maxvalue = OFstatic_cast(Uint16, plut->getAbsMaxRange() - 1); for (i = 0; i < ocnt; ++i) { value = OFstatic_cast(Uint32, OFstatic_cast(double, i) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, maxvalue - plut->getValue(value)))); } } else { // normal for (i = 0; i < ocnt; ++i) { value = OFstatic_cast(Uint32, OFstatic_cast(double, i) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(plut->getValue(value))); } } } else { // don't use display: invalid or absent for (i = 0; i < ocnt; ++i) { value = OFstatic_cast(Uint32, OFstatic_cast(double, i) * gradient1); *(q++) = OFstatic_cast(T3, OFstatic_cast(double, low) + OFstatic_cast(double, plut->getValue(value)) * gradient2); } } const T3 *lut0 = lut - OFstatic_cast(T2, inter->getAbsMinimum()); // 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 { if (low > high) // inverse { const Uint16 maxvalue = OFstatic_cast(Uint16, plut->getAbsMaxRange() - 1); for (i = Count; i != 0; --i) { value = OFstatic_cast(Uint32, (OFstatic_cast(double, *(p++)) - absmin) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, maxvalue - plut->getValue(value)))); } } else { // normal for (i = Count; i != 0; --i) { value = OFstatic_cast(Uint32, (OFstatic_cast(double, *(p++)) - absmin) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(plut->getValue(value))); } } } else { // don't use display: invalid or absent for (i = Count; i != 0; --i) { value = OFstatic_cast(Uint32, (OFstatic_cast(double, *(p++)) - absmin) * gradient1); *(q++) = OFstatic_cast(T3, OFstatic_cast(double, low) + OFstatic_cast(double, plut->getValue(value)) * gradient2); } } } } else { // has no presentation LUT createDisplayLUT(dlut, disp, inter->getBits()); register const double gradient = outrange / (inter->getAbsMaxRange()); if (initOptimizationLUT(lut, ocnt)) { // use LUT for optimization q = lut; if (dlut != NULL) // perform display transformation { if (low > high) // inverse { for (i = ocnt; i != 0; --i) // calculating LUT entries *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, i - 1))); } else { // normal for (i = 0; i < ocnt; ++i) // calculating LUT entries *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, i))); } } else { // don't use display: invalid or absent for (i = 0; i < ocnt; ++i) // calculating LUT entries *(q++) = OFstatic_cast(T3, OFstatic_cast(double, low) + OFstatic_cast(double, i) * gradient); } const T3 *lut0 = lut - OFstatic_cast(T2, inter->getAbsMinimum()); // 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 { if (low > high) // inverse { for (i = Count; i != 0; --i) *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, absmax - (OFstatic_cast(double, *(p++)) - absmin)))); } else { // normal for (i = Count; i != 0; --i) *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, OFstatic_cast(double, *(p++)) - absmin))); } } else { // don't use display: invalid or absent for (i = Count; i != 0; --i) *(q++) = OFstatic_cast(T3, OFstatic_cast(double, low) + (OFstatic_cast(double, *(p++)) - absmin) * gradient); } } } 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 VOI window to the output data * ** @param inter pointer to intermediate pixel representation * @param start offset of the first pixel to be processed * @param plut presentation LUT (optional, maybe NULL) * @param disp display function (optional, maybe NULL) * @param center window center * @param width window width (>= 1) * @param low lowest pixel value for the output data (e.g. 0) * @param high highest pixel value for the output data (e.g. 255) */ void window(const DiMonoPixel *inter, const Uint32 start, const DiLookupTable *plut, DiDisplayFunction *disp, const double center, const double width, const T3 low, const T3 high) { const T1 *pixel = OFstatic_cast(const T1 *, inter->getData()); if (pixel != NULL) { if (Data == NULL) Data = new T3[FrameSize]; // create new output buffer if (Data != NULL) {#ifdef DEBUG if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Informationals)) { ofConsole.lockCerr() << "INFO: using VOI routine 'window()'" << endl; ofConsole.unlockCerr(); }#endif const DiDisplayLUT *dlut = NULL; const double absmin = inter->getAbsMinimum(); const double width_1 = width - 1; const double leftBorder = center - 0.5 - width_1 / 2; // window borders, according to supplement 33 const double rightBorder = center - 0.5 + width_1 / 2; const double outrange = OFstatic_cast(double, high) - OFstatic_cast(double, low); // output range const unsigned long ocnt = OFstatic_cast(unsigned long, inter->getAbsMaxRange()); // number of LUT entries register const T1 *p = pixel + start; register T3 *q = Data; register unsigned long i; register double value; T3 *lut = NULL; if ((plut != NULL) && (plut->isValid())) // has presentation LUT {#ifdef DEBUG if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Informationals)) { ofConsole.lockCerr() << "INFO: using presentation LUT transformation" << endl; ofConsole.unlockCerr(); }#endif createDisplayLUT(dlut, disp, plut->getBits()); register Uint32 value2; // presentation LUT is always unsigned const Uint32 pcnt = plut->getCount(); const double plutmax_1 = OFstatic_cast(double, plut->getAbsMaxRange()) - 1; const double gradient1 = (width_1 == 0) ? 0 : OFstatic_cast(double, pcnt - 1) / width_1; 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 gradient2 = (low > high) ? (-maxvalue / plutmax_1) : (maxvalue / plutmax_1); for (i = 0; i < ocnt; ++i) { value = OFstatic_cast(double, i) + absmin; // pixel value if (value <= leftBorder) value2 = 0; // first LUT index else if (value > rightBorder) value2 = pcnt - 1; // last LUT index else value2 = OFstatic_cast(Uint32, (value - leftBorder) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, offset + OFstatic_cast(double, plut->getValue(value2)) * gradient2))); } } else { // don't use display: invalid or absent const double gradient2 = outrange / plutmax_1; for (i = 0; i < ocnt; ++i) { value = OFstatic_cast(double, i) + absmin; // pixel value if (value <= leftBorder) value2 = 0; // first LUT index else if (value > rightBorder) 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); } } 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 gradient2 = (low > high) ? (-maxvalue / plutmax_1) : (maxvalue / plutmax_1); for (i = Count; i != 0; --i) { value = OFstatic_cast(double, *(p++)); // pixel value if (value <= leftBorder) value2 = 0; // first LUT index else if (value > rightBorder) value2 = pcnt - 1; // last LUT index else value2 = OFstatic_cast(Uint32, (value - leftBorder) * gradient1); *(q++) = OFstatic_cast(T3, dlut->getValue(OFstatic_cast(Uint16, offset + OFstatic_cast(double, plut->getValue(value2)) * gradient2))); } } else { // don't use display: invalid or absent const double gradient2 = outrange / plutmax_1; for (i = Count; i != 0; --i) { value = OFstatic_cast(double, *(p++)); // pixel value if (value <= leftBorder) value2 = 0; // first LUT index else if (value > rightBorder)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -