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
00031
00032
00033
00034
#ifndef DIQTCMAP_H
00035
#define DIQTCMAP_H
00036
00037
#include "osconfig.h"
00038
#include "diqttype.h"
00039
#include "dcmimage.h"
00040
#include "diqtstab.h"
00041
#include "diqtpix.h"
00042
#include "diqthash.h"
00043
#include "diqtctab.h"
00044
00045
class DicomImage;
00046
class DcmQuantColorHashTable;
00047
class DcmQuantColorTable;
00048
class DcmQuantPixel;
00049
class DcmQuantScaleTable;
00050
00051
00058
template <
class T1,
class T2>
00059 class DcmQuantColorMapping
00060 {
00061
public:
00062
00080 static void create(
00081
DicomImage& sourceImage,
00082
unsigned long frameNumber,
00083
unsigned long maxval,
00084
DcmQuantColorHashTable& cht,
00085
DcmQuantColorTable& colormap,
00086 T1& fs,
00087 T2 *tp)
00088 {
00089
unsigned long cols = sourceImage.
getWidth();
00090
unsigned long rows = sourceImage.
getHeight();
00091
const int bits =
sizeof(DcmQuantComponent)*8;
00092
DcmQuantPixel px;
00093
long limitcol;
00094
long col;
00095
long maxval_l = OFstatic_cast(
long, maxval);
00096
register int ind;
00097
const DcmQuantComponent *currentpixel;
00098
register DcmQuantComponent cr, cg, cb;
00099
00100
00101
DcmQuantScaleTable scaletable;
00102 scaletable.
createTable(OFstatic_cast(DcmQuantComponent, -1), maxval);
00103
00104
const void *data = sourceImage.
getOutputData(bits, frameNumber, 0);
00105
if (data)
00106 {
00107
const DcmQuantComponent *cp = OFstatic_cast(
const DcmQuantComponent *, data);
00108
for (
unsigned long row = 0; row < rows; ++row)
00109 {
00110 fs.startRow(col, limitcol);
00111
do
00112 {
00113 currentpixel = cp + col + col + col;
00114 cr = *currentpixel++;
00115 cg = *currentpixel++;
00116 cb = *currentpixel;
00117 px.
scale(cr, cg, cb, scaletable);
00118
00119 fs.adjust(px, col, maxval_l);
00120
00121
00122 ind = cht.
lookup(px);
00123
if (ind < 0)
00124 {
00125 ind = colormap.
computeIndex(px);
00126 cht.
add(px, ind);
00127 }
00128
00129 fs.propagate(px, colormap.
getPixel(ind), col);
00130 tp[col] = OFstatic_cast(T2, ind);
00131 fs.nextCol(col);
00132 }
while ( col != limitcol );
00133 fs.finishRow();
00134 cp += (cols * 3);
00135 tp += cols;
00136 }
00137 }
00138 }
00139 };
00140
00141
00142
#endif
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160