123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- /***************************************************************************
- * E-Com Technology Ltd.
- *
- * ECOMPACS DICOM Network Transport Libraries * Version 0.1 Beta
- ***************************************************************************/
- #ifndef __IMAGE_LOOKUP_TABLE__
- #define __IMAGE_LOOKUP_TABLE__
- #pragma warning (disable : 4251)
- class RealImage;
- class DICOM_API LookupTable
- {
- public:
- Array <int> MinForkCalibArray;
- Array <int> MaxForkCalibArray;
- int MinForkCalib; // current min fork position (Calib value)
- int MaxForkCalib; // current max fork position (Calib value)
- BOOL BlackSaturated; // flag for black saturation
- // The current curve is supposed to be constant
- // between minSpaceCalib and minForkCalib and between
- // maxForkCalib and maxSpaceCalib and is varying
- // between minForkCalib and maxForkCalib.
- public:
- LookupTable ();
- LookupTable ( const LookupTable & LUT);
- LookupTable (int minSpaceRaw,
- int maxSpaceRaw,
- float offset,
- float slope,
- int wwCal, // window width
- int wlCal) // window level
- {
- Init (minSpaceRaw, maxSpaceRaw, offset, slope, wwCal, wlCal);
- }
- ~LookupTable ();
- public:
- void Init ( int minSpaceRaw,
- int maxSpaceRaw,
- float offset,
- float slope,
- int wwCal, // window width
- int wlCal); // window level
- void AddMinMaxFork (int minForkCal, int maxForkCal)
- {
- if (minForkCal < MinSpaceCalib) minForkCal = MinSpaceCalib;
- else
- if (minForkCal > MaxSpaceCalib) minForkCal = MaxSpaceCalib;
- if (maxForkCal < MinSpaceCalib) maxForkCal = MinSpaceCalib;
- else
- if (maxForkCal > MaxSpaceCalib) maxForkCal = MaxSpaceCalib;
- MinForkCalibArray.Add (minForkCal);
- MaxForkCalibArray.Add (maxForkCal);
- }
- void SetMinMaxFork (int minForkCal, int maxForkCal)
- {
- if (minForkCal < MinSpaceCalib) minForkCal = MinSpaceCalib;
- else
- if (minForkCal > MaxSpaceCalib) minForkCal = MaxSpaceCalib;
- if (maxForkCal < MinSpaceCalib) maxForkCal = MinSpaceCalib;
- else
- if (maxForkCal > MaxSpaceCalib) maxForkCal = MaxSpaceCalib;
- MinForkCalib = minForkCal;
- MaxForkCalib = maxForkCal;
- }
- int GetMinSpaceCalib () const { return MinSpaceCalib; }
- int GetMaxSpaceCalib () const { return MaxSpaceCalib; }
- int GetMinSpaceRaw () const { return MinSpaceRaw; }
- int GetMaxSpaceRaw () const { return MaxSpaceRaw; }
- int GetImageRangeRaw () const { return ImageRangeRaw; }
-
- float GetIntercept () const { return Intercept; }
- float GetSlope () const { return Slope; }
- //**************************************************************************
- // Purpose: Create and compute the color transformation table that
- // translates the real image values into the pixmap ones,
- // (first apply the min and max, then apply the curve then
- // convert it from 256 to 240 color levels).
- // The created transformation tab is returned as the result
- // of the method.
- //**************************************************************************
- BYTE * CreateLookupTable (int depth) const;
- BYTE * CreateLookupTableEx (int depth) const;
- //**************************************************************************
- // Name: ComputeCalibratedValue
- //
- // Purpose: Translates from screen value to calibrated value.
- //**************************************************************************
- int ComputeCalibratedValue (int screenValue) const
- {
- return (int) (((((float) (MaxSpaceRaw - MinSpaceRaw) *
- (float) (screenValue) / 255.0) +
- (float) MinSpaceRaw) * Slope) + Intercept);
- }
- //**************************************************************************
- // Name: ComputeScreenValue
- //
- // Purpose: Translates from calibrated value to screen value.
- //**************************************************************************
- int ComputeScreenValue (int calibratedValue) const
- {
- return (int) (((( (float) calibratedValue - Intercept) / Slope) -
- (float) MinSpaceRaw) * 255.0 /
- (float) (MaxSpaceRaw - MinSpaceRaw + 1));
- }
- //**************************************************************************
- // Name: FromRawToCalibrated
- //
- // Purpose: Translates from raw value to calibrated one.
- //**************************************************************************
- int FromRawToCalibrated (int Raw) const
- {
- return (int) (((float) Raw * Slope) + Intercept);
- }
- //**************************************************************************
- // Name: FromCalibratedToRaw
- //
- // Purpose: Translates from Calibrated value to raw one.
- //**************************************************************************
- int FromCalibratedToRaw (int Cal) const
- {
- return (int) (((float) Cal - Intercept) / Slope);
- }
- private:
- RealImage * RealImage;
- int MaxSpaceCalib; // maximum intensity of the image (Calib value)
- int MinSpaceCalib; // minimum intensity of the image (Calib value)
- int MaxSpaceRaw; // maximum intensity of the image (Raw value)
- int MinSpaceRaw; // minimum intensity of the image (Raw value)
- int MinSpaceSet; // min pixel value of the set of images
- int MaxSpaceSet; // max pixel value of the set of images
- int ImageRangeRaw; // the image dynamic
-
- float Intercept; // offset for the real pixel values
- float Slope; // factor for real pixel slope
- private:
- friend class ImageProcess;
- friend class DICOMImage;
- friend class RealImage;
- friend class RealImage8;
- friend class RealImage16;
- friend class RealImageRGB;
- };
- #endif
|