📄 discalet.h
字号:
if (xneed) { ++q; v = HALFSCALE_FACTOR; xneed = 0; } v += xleft * OFstatic_cast(signed long, *p); xfill -= xleft; } } if (xfill > 0) v += xfill * OFstatic_cast(signed long, *(--p)); if (!xneed) { v /= SCALE_FACTOR; *q = OFstatic_cast(T, (v > maxvalue) ? maxvalue : v); } sq += this->Dest_X; } } } } } delete[] xtemp; delete[] xvalue; } /** free scaling method with interpolation (only for expansion). * ** @param src array of pointers to source image pixels * @param dest array of pointers to destination image pixels */ void expandPixel(const T *src[], T *dest[]) {#ifdef DEBUG if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Informationals)) { ofConsole.lockCerr() << "INFO: expandPixel with interpolated c't algorithm" << endl; ofConsole.unlockCerr(); }#endif const double x_factor = OFstatic_cast(double, this->Src_X) / OFstatic_cast(double, this->Dest_X); const double y_factor = OFstatic_cast(double, this->Src_Y) / OFstatic_cast(double, this->Dest_Y); const unsigned long f_size = OFstatic_cast(unsigned long, Rows) * OFstatic_cast(unsigned long, Columns); const T *sp; double bx, ex; double by, ey; int bxi, exi; int byi, eyi; unsigned long offset; double value, sum; double x_part, y_part; double l_factor, r_factor; double t_factor, b_factor; register int xi; register int yi; register Uint16 x; register Uint16 y; register const T *p; register T *q; /* * based on scaling algorithm from "c't - Magazin fuer Computertechnik" (c't 11/94) * (adapted to be used with signed pixel representation and inverse images - mono1) */ for (int j = 0; j < this->Planes; ++j) { sp = src[j] + OFstatic_cast(unsigned long, Top) * OFstatic_cast(unsigned long, Columns) + Left; q = dest[j]; for (Uint32 f = 0; f < this->Frames; ++f) { for (y = 0; y < this->Dest_Y; ++y) { by = y_factor * OFstatic_cast(double, y); ey = y_factor * (OFstatic_cast(double, y) + 1.0); byi = OFstatic_cast(int, by); eyi = OFstatic_cast(int, ey); if (OFstatic_cast(double, eyi) == ey) --eyi; y_part = OFstatic_cast(double, eyi) / y_factor; b_factor = y_part - OFstatic_cast(double, y); t_factor = (OFstatic_cast(double, y) + 1.0) - y_part; for (x = 0; x < this->Dest_X; ++x) { value = 0; bx = x_factor * OFstatic_cast(double, x); ex = x_factor * (OFstatic_cast(double, x) + 1.0); bxi = OFstatic_cast(int, bx); exi = OFstatic_cast(int, ex); if (OFstatic_cast(double, exi) == ex) --exi; x_part = OFstatic_cast(double, exi) / x_factor; l_factor = x_part - OFstatic_cast(double, x); r_factor = (OFstatic_cast(double, x) + 1.0) - x_part; offset = OFstatic_cast(unsigned long, byi - 1) * OFstatic_cast(unsigned long, Columns); for (yi = byi; yi <= eyi; ++yi) { offset += Columns; p = sp + offset + OFstatic_cast(unsigned long, bxi); for (xi = bxi; xi <= exi; ++xi) { sum = OFstatic_cast(double, *(p++)); if (bxi != exi) { if (xi == bxi) sum *= l_factor; else sum *= r_factor; } if (byi != eyi) { if (yi == byi) sum *= b_factor; else sum *= t_factor; } value += sum; } } *(q++) = OFstatic_cast(T, value + 0.5); } } sp += f_size; // skip to next frame start: UNTESTED } } } /** free scaling method with interpolation (only for reduction). * ** @param src array of pointers to source image pixels * @param dest array of pointers to destination image pixels */ void reducePixel(const T *src[], T *dest[]) {#ifdef DEBUG if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Informationals | DicomImageClass::DL_Warnings)) { ofConsole.lockCerr() << "INFO: reducePixel with interpolated c't algorithm ... still a little BUGGY !" << endl; ofConsole.unlockCerr(); }#endif const double x_factor = OFstatic_cast(double, this->Src_X) / OFstatic_cast(double, this->Dest_X); const double y_factor = OFstatic_cast(double, this->Src_Y) / OFstatic_cast(double, this->Dest_Y); const double xy_factor = x_factor * y_factor; const unsigned long f_size = OFstatic_cast(unsigned long, Rows) * OFstatic_cast(unsigned long, Columns); const T *sp; double bx, ex; double by, ey; int bxi, exi; int byi, eyi; unsigned long offset; double value, sum; double l_factor, r_factor; double t_factor, b_factor; register int xi; register int yi; register Uint16 x; register Uint16 y; register const T *p; register T *q; /* * based on scaling algorithm from "c't - Magazin fuer Computertechnik" (c't 11/94) * (adapted to be used with signed pixel representation and inverse images - mono1) */ for (int j = 0; j < this->Planes; ++j) { sp = src[j] + OFstatic_cast(unsigned long, Top) * OFstatic_cast(unsigned long, Columns) + Left; q = dest[j]; for (Uint32 f = 0; f < this->Frames; ++f) { for (y = 0; y < this->Dest_Y; ++y) { by = y_factor * OFstatic_cast(double, y); ey = y_factor * (OFstatic_cast(double, y) + 1.0); byi = OFstatic_cast(int, by); eyi = OFstatic_cast(int, ey); if (OFstatic_cast(double, eyi) == ey) --eyi; b_factor = 1 + OFstatic_cast(double, byi) - by; t_factor = ey - OFstatic_cast(double, eyi); for (x = 0; x < this->Dest_X; ++x) { value = 0; bx = x_factor * OFstatic_cast(double, x); ex = x_factor * (OFstatic_cast(double, x) + 1.0); bxi = OFstatic_cast(int, bx); exi = OFstatic_cast(int, ex); if (OFstatic_cast(double, exi) == ex) --exi; l_factor = 1 + OFstatic_cast(double, bxi) - bx; r_factor = ex - OFstatic_cast(double, exi); offset = OFstatic_cast(unsigned long, byi - 1) * OFstatic_cast(unsigned long, Columns); for (yi = byi; yi <= eyi; ++yi) { offset += Columns; p = sp + offset + OFstatic_cast(unsigned long, bxi); for (xi = bxi; xi <= exi; ++xi) { sum = OFstatic_cast(double, *(p++)) / xy_factor; if (xi == bxi) sum *= l_factor; else if (xi == exi) sum *= r_factor; if (yi == byi) sum *= b_factor; else if (yi == eyi) sum *= t_factor; value += sum; } } *(q++) = OFstatic_cast(T, value + 0.5); } } sp += f_size; // skip to next frame start: UNTESTED } } }};#endif/* * * CVS/RCS Log: * $Log: discalet.h,v $ * Revision 1.25 2005/12/08 16:48:09 meichel * Changed include path schema for all DCMTK header files * * Revision 1.24 2004/04/21 10:00:36 meichel * Minor modifications for compilation with gcc 3.4.0 * * Revision 1.23 2004/01/05 14:52:20 joergr * Removed acknowledgements with e-mail addresses from CVS log. * * Revision 1.22 2003/12/23 15:53:22 joergr * Replaced post-increment/decrement operators by pre-increment/decrement * operators where appropriate (e.g. 'i++' by '++i'). * * Revision 1.21 2003/12/09 10:25:06 joergr * Adapted type casts to new-style typecast operators defined in ofcast.h. * Removed leading underscore characters from preprocessor symbols (reserved * symbols). Updated copyright header. * * Revision 1.20 2002/12/09 13:32:56 joergr * Renamed parameter/local variable to avoid name clashes with global * declaration left and/or right (used for as iostream manipulators). * * Revision 1.19 2002/04/16 13:53:12 joergr * Added configurable support for C++ ANSI standard includes (e.g. streams). * * Revision 1.18 2001/06/01 15:49:51 meichel * Updated copyright header * * Revision 1.17 2000/05/03 09:46:29 joergr * Removed most informational and some warning messages from release built * (#ifndef DEBUG). * * Revision 1.16 2000/04/28 12:32:33 joergr * DebugLevel - global for the module - now derived from OFGlobal (MF-safe). * * Revision 1.15 2000/04/27 13:08:42 joergr * Dcmimgle library code now consistently uses ofConsole for error output. * * Revision 1.14 2000/03/08 16:24:24 meichel * Updated copyright header. * * Revision 1.13 2000/03/07 16:15:13 joergr * Added explicit type casts to make Sun CC 2.0.1 happy. * * Revision 1.12 2000/03/03 14:09:14 meichel * Implemented library support for redirecting error messages into memory * instead of printing them to stdout/stderr for GUI applications. * * Revision 1.11 1999/11/19 12:37:19 joergr * Fixed bug in scaling method "reducePixel" (reported by gcc 2.7.2.1). * * Revision 1.10 1999/09/17 13:07:20 joergr * Added/changed/completed DOC++ style comments in the header files. * Enhanced efficiency of some "for" loops. * * Revision 1.9 1999/08/25 16:41:55 joergr * Added new feature: Allow clipping region to be outside the image * (overlapping). * * Revision 1.8 1999/07/23 14:09:24 joergr * Added new interpolation algorithm for scaling. * * Revision 1.7 1999/04/28 14:55:05 joergr * Introduced new scheme for the debug level variable: now each level can be * set separately (there is no "include" relationship). * * Revision 1.6 1999/03/24 17:20:24 joergr * Added/Modified comments and formatting. * * Revision 1.5 1999/02/11 16:42:10 joergr * Removed inline declarations from several methods. * * Revision 1.4 1999/02/03 17:35:14 joergr * Moved global functions maxval() and determineRepresentation() to class * DicomImageClass (as static methods). * * Revision 1.3 1998/12/22 14:39:44 joergr * Added some preparation to enhance interpolated scaling (clipping and * scaling) in the future. * * Revision 1.2 1998/12/16 16:39:45 joergr * Implemented combined clipping and scaling for pixel replication and * suppression. * * Revision 1.1 1998/11/27 15:47:11 joergr * Added copyright message. * Combined clipping and scaling methods. * * Revision 1.4 1998/05/11 14:53:29 joergr * Added CVS/RCS header to each file. * * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -