00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIQTCMAP_H
00031 #define DIQTCMAP_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034 #include "dcmtk/dcmimage/diqttype.h"
00035 #include "dcmtk/dcmimgle/dcmimage.h"
00036 #include "dcmtk/dcmimage/diqtstab.h"
00037 #include "dcmtk/dcmimage/diqtpix.h"
00038 #include "dcmtk/dcmimage/diqthash.h"
00039 #include "dcmtk/dcmimage/diqtctab.h"
00040
00041 class DicomImage;
00042 class DcmQuantColorHashTable;
00043 class DcmQuantColorTable;
00044 class DcmQuantPixel;
00045 class DcmQuantScaleTable;
00046
00047
00054 template <class T1, class T2>
00055 class DcmQuantColorMapping
00056 {
00057 public:
00058
00076 static void create(
00077 DicomImage& sourceImage,
00078 unsigned long frameNumber,
00079 unsigned long maxval,
00080 DcmQuantColorHashTable& cht,
00081 DcmQuantColorTable& colormap,
00082 T1& fs,
00083 T2 *tp)
00084 {
00085 unsigned long cols = sourceImage.getWidth();
00086 unsigned long rows = sourceImage.getHeight();
00087 const int bits = sizeof(DcmQuantComponent)*8;
00088 DcmQuantPixel px;
00089 long limitcol;
00090 long col;
00091 long maxval_l = OFstatic_cast(long, maxval);
00092 register int ind;
00093 const DcmQuantComponent *currentpixel;
00094 register DcmQuantComponent cr, cg, cb;
00095
00096
00097 DcmQuantScaleTable scaletable;
00098 scaletable.createTable(OFstatic_cast(DcmQuantComponent, -1), maxval);
00099
00100 const void *data = sourceImage.getOutputData(bits, frameNumber, 0);
00101 if (data)
00102 {
00103 const DcmQuantComponent *cp = OFstatic_cast(const DcmQuantComponent *, data);
00104 for (unsigned long row = 0; row < rows; ++row)
00105 {
00106 fs.startRow(col, limitcol);
00107 do
00108 {
00109 currentpixel = cp + col + col + col;
00110 cr = *currentpixel++;
00111 cg = *currentpixel++;
00112 cb = *currentpixel;
00113 px.scale(cr, cg, cb, scaletable);
00114
00115 fs.adjust(px, col, maxval_l);
00116
00117
00118 ind = cht.lookup(px);
00119 if (ind < 0)
00120 {
00121 ind = colormap.computeIndex(px);
00122 cht.add(px, ind);
00123 }
00124
00125 fs.propagate(px, colormap.getPixel(ind), col);
00126 tp[col] = OFstatic_cast(T2, ind);
00127 fs.nextCol(col);
00128 } while ( col != limitcol );
00129 fs.finishRow();
00130 cp += (cols * 3);
00131 tp += cols;
00132 }
00133 }
00134 }
00135 };
00136
00137
00138 #endif
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162