1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
/*
*
* Copyright (C) 1998-2005, OFFIS
*
* This software and supporting documentation were developed by
*
* Kuratorium OFFIS e.V.
* Healthcare Information and Communication Systems
* Escherweg 2
* D-26121 Oldenburg, Germany
*
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
* Module: dcmpstat
*
* Author: Marco Eichelberg
*
* Purpose:
* classes: DVPSPresentationLUT
*
* Last Update: $Author: meichel $
* Update Date: $Date: 2005/12/08 15:46:39 $
* CVS/RCS Revision: $Revision: 1.3 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
*
*/
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/dcmpstat/dvpspl.h"
#include "dcmtk/dcmimgle/dcmimage.h" /* for class DiLookupTable, DicomImage */
#include "dcmtk/dcmpstat/dvpsdef.h" /* for constants and macros */
#include "dcmtk/dcmnet/dimse.h"
/* --------------- class DVPSPresentationLUT --------------- */
OFBool DVPSPresentationLUT::compareDiLookupTable(DiLookupTable *lut)
{
if ((presentationLUT == DVPSP_table) && lut
&& (0 == lut->compareLUT(presentationLUTData, presentationLUTDescriptor))) return OFTrue;
return OFFalse;
}
DiLookupTable *DVPSPresentationLUT::createDiLookupTable()
{
DiLookupTable *result = NULL;
if (presentationLUT == DVPSP_table) result = new DiLookupTable(presentationLUTData, presentationLUTDescriptor);
return result;
}
OFCondition DVPSPresentationLUT::invert()
{
OFCondition status = EC_Normal;
switch (presentationLUT)
{
case DVPSP_identity:
presentationLUT = DVPSP_inverse;
break;
case DVPSP_inverse:
presentationLUT = DVPSP_identity;
break;
case DVPSP_table:
status = EC_IllegalCall;
if (haveTable())
{
DiLookupTable *lut = new DiLookupTable(presentationLUTData, presentationLUTDescriptor);
if (lut && (lut->mirrorTable(0x2))) status = EC_Normal; // flag = 0x2: mirror only original LUT data
delete lut;
}
break;
case DVPSP_lin_od:
status = EC_IllegalCall;
break;
}
return status;
}
OFBool DVPSPresentationLUT::activate(DicomImage *image, OFBool printLUT)
{
if (image==NULL) return OFFalse;
int result=0;
switch (presentationLUT)
{
case DVPSP_identity:
if (printLUT)
{
// in DICOM print, IDENTITY should not invert a MONOCHROME1 image
result = image->setPresentationLutShape(ESP_Default);
}
else
{
result = image->setPresentationLutShape(ESP_Identity);
}
if ((!result) && verboseMode)
{
logstream->lockCerr() << "warning: unable to set identity presentation LUT shape, ignoring." << endl;
logstream->unlockCerr();
}
break;
case DVPSP_inverse:
if (!printLUT)
result = image->setPresentationLutShape(ESP_Inverse);
if ((!result) && verboseMode)
{
logstream->lockCerr() << "warning: unable to set inverse presentation LUT shape, ignoring." << endl;
logstream->unlockCerr();
}
break;
case DVPSP_lin_od:
result = image->setPresentationLutShape(ESP_LinOD);
if ((!result) && verboseMode)
{
logstream->lockCerr() << "warning: unable to set linear optical density presentation LUT shape, ignoring." << endl;
logstream->unlockCerr();
}
break;
case DVPSP_table:
if (printLUT)
result = image->setVoiLut(presentationLUTData, presentationLUTDescriptor, &presentationLUTExplanation);
else
result = image->setPresentationLut(presentationLUTData, presentationLUTDescriptor, &presentationLUTExplanation);
if ((!result) && verboseMode)
{
logstream->lockCerr() << "warning: unable to set presentation LUT, ignoring." << endl;
logstream->unlockCerr();
}
break;
}
if (result) return OFTrue; else return OFFalse;
}
OFBool DVPSPresentationLUT::activateInverseLUT(DicomImage *image)
{
int result = 0;
if ((image != NULL) && (presentationLUT == DVPSP_table))
{
result = image->setInversePresentationLut(presentationLUTData, presentationLUTDescriptor);
if ((!result) && verboseMode)
{
logstream->lockCerr() << "warning: unable to set inverse presentation LUT, ignoring." << endl;
logstream->unlockCerr();
}
}
if (result) return OFTrue; else return OFFalse;
}
OFBool DVPSPresentationLUT::isInverse()
{
OFBool result = OFFalse;
switch (presentationLUT)
{
case DVPSP_identity:
case DVPSP_lin_od:
break;
case DVPSP_inverse:
result = OFTrue;
break;
case DVPSP_table:
if ((presentationLUTDescriptor.getVM()==3)&&(presentationLUTData.getLength() > 0))
{
DiLookupTable *lut = new DiLookupTable(presentationLUTData, presentationLUTDescriptor);
if (lut && (lut->getFirstValue() > lut->getLastValue())) result = OFTrue;
delete lut;
}
break;
}
return result;
}
/*
* $Log: dvpspl2.cc,v $
* Revision 1.3 2005/12/08 15:46:39 meichel
* Changed include path schema for all DCMTK header files
*
* Revision 1.2 2003/12/18 17:14:47 meichel
* Fixed print preview for MONOCHROME1 images with IDENTITY P-LUT shape
*
* Revision 1.1 2003/08/27 14:59:08 meichel
* Moved all methods of class DVPSPresentationLUT that depend on module dcmimgle
* into a separate implementation file
*
*
*/
|