33 #include "dcmtk/config/osconfig.h" 34 #include "dcmtk/dcmimage/diqttype.h" 35 #include "dcmtk/dcmimgle/dcmimage.h" 36 #include "dcmtk/dcmimage/diqtstab.h" 37 #include "dcmtk/dcmimage/diqtpix.h" 38 #include "dcmtk/dcmimage/diqthash.h" 39 #include "dcmtk/dcmimage/diqtctab.h" 54 template <
class T1,
class T2>
78 unsigned long frameNumber,
85 unsigned long cols = sourceImage.
getWidth();
86 unsigned long rows = sourceImage.
getHeight();
87 const int bits =
sizeof(DcmQuantComponent)*8;
91 long maxval_l = OFstatic_cast(
long, maxval);
93 const DcmQuantComponent *currentpixel;
94 register DcmQuantComponent cr, cg, cb;
98 scaletable.
createTable(OFstatic_cast(DcmQuantComponent, -1), maxval);
100 const void *data = sourceImage.
getOutputData(bits, frameNumber, 0);
103 const DcmQuantComponent *cp = OFstatic_cast(
const DcmQuantComponent *, data);
104 for (
unsigned long row = 0; row < rows; ++row)
106 fs.startRow(col, limitcol);
109 currentpixel = cp + col + col + col;
110 cr = *currentpixel++;
111 cg = *currentpixel++;
113 px.
scale(cr, cg, cb, scaletable);
115 fs.adjust(px, col, maxval_l);
125 fs.propagate(px, colormap.
getPixel(ind), col);
126 tp[col] = OFstatic_cast(T2, ind);
128 }
while ( col != limitcol );
const void * getOutputData(const int bits=0, const unsigned long frame=0, const int planar=0)
render pixel data and return pointer to internal memory buffer.
objects of this class represent individual RGB pixels.
const DcmQuantPixel & getPixel(unsigned long idx) const
returns the color at index idx.
unsigned long getHeight() const
get image height in pixels
template class that maps a color image into a palette color image with given color palette...
this class implements a hash table for colors.
this class implements a color table that can either be a look-up table or an image color histogram...
this is a helper class used for temporarily reducing the image bit depth during calculation of an ima...
void add(const DcmQuantPixel &colorP, int value)
adds a new color to the hash table.
void createTable(unsigned long oldmaxval, unsigned long newmaxval)
initializes the look-up table.
static void create(DicomImage &sourceImage, unsigned long frameNumber, unsigned long maxval, DcmQuantColorHashTable &cht, DcmQuantColorTable &colormap, T1 &fs, T2 *tp)
converts a single frame of a color image into a palette color image.
int lookup(const DcmQuantPixel &colorP) const
looks up the given color in the hash table.
int computeIndex(const DcmQuantPixel &px) const
determines for a given color the closest match in the color LUT.
Interface class for dcmimgle/dcmimage module.
void scale(DcmQuantComponent r, DcmQuantComponent g, DcmQuantComponent b, const DcmQuantScaleTable &table)
assigns new R, G and B values to this pixel using the given scale table in which all three values are...
unsigned long getWidth() const
get image width in pixels