📄 dimopxt.h
字号:
register unsigned long i; OFBitmanipTemplate<Uint32>::zeroMem(quant, count); // initialize array for (i = 0; i < Count; ++i) { if ((Data[i] >= MinValue[0]) && (Data[i] <= MaxValue[0])) // only for stability ! ++quant[OFstatic_cast(Uint32, Data[i] - MinValue[0])]; // count values#ifdef DEBUG else if (DicomImageClass::checkDebugLevel(DicomImageClass::DL_Warnings)) { ofConsole.lockCerr() << "WARNING: invalid value (" << Data[i] << ") in " << "int DiMonoPixelTemplate<T>::getHistogramWindow() ! " << endl; ofConsole.unlockCerr(); }#endif } const Uint32 threshvalue = OFstatic_cast(Uint32, thresh * OFstatic_cast(double, Count)); register Uint32 t = 0; i = 0; while ((i < count) && (t < threshvalue)) t += quant[i++]; const T minvalue = (i < count) ? OFstatic_cast(T, MinValue[0] + i) : 0; t = 0; i = count; while ((i > 0) && (t < threshvalue)) t += quant[--i]; const T maxvalue = (i > 0) ? OFstatic_cast(T, MinValue[0] + i) : 0; delete[] quant; if (minvalue < maxvalue) { /* suppl. 33: "A Window Center of 2^n-1 and a Window Width of 2^n selects the range of input values from 0 to 2^n-1." */ center = (OFstatic_cast(double, minvalue) + OFstatic_cast(double, maxvalue) + 1) / 2; width = OFstatic_cast(double, maxvalue) - OFstatic_cast(double, minvalue) + 1; return (width > 0); } } } return 0; } protected: /** constructor * ** @param pixel pointer to intermediate pixel data (not necessarily monochrome) * @param modality pointer to object managing modality transform */ DiMonoPixelTemplate(const DiPixel *pixel, DiMonoModality *modality) : DiMonoPixel(pixel, modality), Data(NULL) { MinValue[0] = 0; MinValue[1] = 0; MaxValue[0] = 0; MaxValue[1] = 0; } /** constructor * ** @param pixel pointer to intermediate monochrome pixel data * @param count number of pixels */ DiMonoPixelTemplate(const DiMonoPixel *pixel, const unsigned long count) : DiMonoPixel(pixel, count), Data(NULL) { MinValue[0] = 0; MinValue[1] = 0; MaxValue[0] = 0; MaxValue[1] = 0; } /** determine minimum and maximum pixelvalues * ** @param minvalue starting global minimum value (0 = invalid) * @param maxvalue starting global maximum value (0 = invalid) * @param mode calculate global min/max if 0x1 bit is set (default), * calculate next min/max if 0x2 bit is set */ void determineMinMax(T minvalue = 0, T maxvalue = 0, const int mode = 0x1) { if (Data != NULL) { if (mode & 0x1) { if ((minvalue == 0) && (maxvalue == 0)) { register T *p = Data; register T value = *p; register unsigned long i; minvalue = value; maxvalue = value; for (i = Count; i > 1; --i) // could be optimized if necessary (see diinpxt.h) ! { value = *(++p); if (value < minvalue) minvalue = value; else if (value > maxvalue) maxvalue = value; } } MinValue[0] = minvalue; // global minimum MaxValue[0] = maxvalue; // global maximum MinValue[1] = 0; // invalidate value MaxValue[1] = 0; } else { minvalue = MinValue[0]; maxvalue = MaxValue[0]; } if (mode & 0x2) { register T *p = Data; register T value; register int firstmin = 1; register int firstmax = 1; register unsigned long i; for (i = Count; i != 0; --i) // could be optimized if necessary (see diinpxt.h) ! { value = *(p++); if ((value > minvalue) && ((value < MinValue[1]) || firstmin)) { MinValue[1] = value; firstmin = 0; } if ((value < maxvalue) && ((value > MaxValue[1]) || firstmax)) { MaxValue[1] = value; firstmax = 0; } } } } } /// pointer to pixel data T *Data; private: /// minimum pixel values (0 = global, 1 = ignoring global) T MinValue[2]; /// maximum pixel values T MaxValue[2]; // --- declarations to avoid compiler warnings DiMonoPixelTemplate(const DiMonoPixelTemplate<T> &); DiMonoPixelTemplate<T> &operator=(const DiMonoPixelTemplate<T> &);};#endif/* * * CVS/RCS Log: * $Log: dimopxt.h,v $ * Revision 1.27 2005/12/08 16:47:56 meichel * Changed include path schema for all DCMTK header files * * Revision 1.26 2004/10/19 12:58:24 joergr * Enhanced API documentation. * * Revision 1.25 2004/02/06 11:07:50 joergr * Distinguish more clearly between const and non-const access to pixel data. * * Revision 1.24 2004/01/05 14:52:20 joergr * Removed acknowledgements with e-mail addresses from CVS log. * * Revision 1.23 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.22 2003/12/09 10:02:04 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.21 2002/12/09 13:32:54 joergr * Renamed parameter/local variable to avoid name clashes with global * declaration left and/or right (used for as iostream manipulators). * * Revision 1.20 2002/10/21 10:13:51 joergr * Corrected wrong calculation of min/max pixel value in cases where the * stored pixel data exceeds the expected size. * * Revision 1.19 2002/06/26 16:05:43 joergr * Enhanced handling of corrupted pixel data and/or length. * * Revision 1.18 2001/11/19 12:56:27 joergr * Added parameter 'frame' to setRoiWindow(). * * Revision 1.17 2001/09/28 13:09:30 joergr * Added method setRoiWindow() which automatically calculates a min-max VOI * window for a specified rectangular region of the image. * Made min-max window calculation consistent with latest release of the DICOM * standard (supplement 33). * * Revision 1.16 2001/06/01 15:49:47 meichel * Updated copyright header * * Revision 1.15 2000/05/03 09:46:29 joergr * Removed most informational and some warning messages from release built * (#ifndef DEBUG). * * Revision 1.14 2000/04/28 12:32:32 joergr * DebugLevel - global for the module - now derived from OFGlobal (MF-safe). * * Revision 1.13 2000/04/27 13:08:41 joergr * Dcmimgle library code now consistently uses ofConsole for error output. * * Revision 1.12 2000/03/08 16:24:21 meichel * Updated copyright header. * * Revision 1.11 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.10 1999/10/06 13:44:35 joergr * Corrected creation of PrintBitmap pixel data: VOI windows should be applied * before clipping to avoid that the region outside the image (border) is also * windowed (this requires a new method in dcmimgle to create a DicomImage * with the grayscale transformations already applied). * * Revision 1.9 1999/09/17 12:42:40 joergr * Added/changed/completed DOC++ style comments in the header files. * Enhanced efficiency of the implementation to determine min/max values of * the input pixels. * * Revision 1.8 1999/05/31 12:35:16 joergr * Corrected bug concerning the conversion of color images to grayscale. * * Revision 1.7 1999/04/30 16:10:51 meichel * Minor code purifications to keep IBM xlC quiet * * Revision 1.6 1999/04/28 14:52:12 joergr * Introduced new scheme for the debug level variable: now each level can be * set separately (there is no "include" relationship). * * Revision 1.5 1999/03/24 17:20:16 joergr * Added/Modified comments and formatting. * * Revision 1.4 1999/01/20 15:11:38 joergr * Replaced invocation of getCount() by member variable Count where possible. * * Revision 1.3 1999/01/11 09:36:13 joergr * Corrected some typos and formatting. * * Revision 1.2 1998/12/22 14:34:30 joergr * Corrected some typos and formatting. * * Revision 1.1 1998/11/27 15:36:43 joergr * Added copyright message. * Replaced delete by delete[] for array types. * Added method to give direct (non-const) access to internal data buffer. * Added support for new bit manipulation class. * * Revision 1.7 1998/07/01 08:39:25 joergr * Minor changes to avoid compiler warnings (gcc 2.8.1 with additional * options), e.g. add copy constructors. * * Revision 1.6 1998/05/11 14:53:23 joergr * Added CVS/RCS header to each file. * * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -