9 #include "fwDcmtkIO/config.hpp" 10 #include "fwDcmtkIO/helper/Codec.hpp" 12 #include <fwMedData/DicomSeries.hpp> 14 #include <fwTools/Type.hpp> 16 #include <dcmtk/config/osconfig.h> 17 #include <dcmtk/dcmdata/dcdeftag.h> 18 #include <dcmtk/dcmdata/dcfilefo.h> 19 #include <dcmtk/dcmdata/dcistrmb.h> 20 #include <dcmtk/dcmimgle/dcmimage.h> 21 #include <dcmtk/dcmnet/diutil.h> 50 const ::fwMemory::BufferObject::sptr& instance,
53 const T* blueLookup,
unsigned short pixelValueBitsAllocated)
55 if(pixelValueBitsAllocated == 16)
57 return ::fwDcmtkIO::reader::rgblookup::ImageRGBLookupLazyReader::createInstanceBuffer<T, Uint16>(
58 rows, columns, instance, redLookup, greenLookup, blueLookup);
62 return ::fwDcmtkIO::reader::rgblookup::ImageRGBLookupLazyReader::createInstanceBuffer<T, Uint8>(
63 rows, columns, instance, redLookup, greenLookup, blueLookup);
78 template<
typename T,
typename U >
80 const ::fwMemory::BufferObject::sptr& instance,
85 DcmFileFormat fileFormat;
93 T* tempoBuffer =
new T[rows * columns * 3];
96 const size_t buffSize = instance->getSize();
97 const std::string dicomPath = instance->getStreamInfo().fsFile.string();
99 char* buffer =
static_cast< char*
>( lock.
getBuffer() );
101 DcmInputBufferStream is;
102 is.setBuffer(buffer, offile_off_t(buffSize));
105 fileFormat.transferInit();
106 if (!fileFormat.read(is).good())
108 FW_RAISE(
"Unable to read Dicom file '"<< dicomPath <<
"'");
111 fileFormat.loadAllDataIntoMemory();
112 fileFormat.transferEnd();
114 dataset = fileFormat.getDataset();
117 dataset->chooseRepresentation(EXS_LittleEndianExplicit,
nullptr);
124 dataset->findAndGetUint8Array(DCM_PixelData, pdata);
125 pixelData = (U*)pdata;
130 dataset->findAndGetUint16Array(DCM_PixelData, pdata);
131 pixelData = (U*)pdata;
136 for (
unsigned int x = 0;
x < columns; ++
x)
138 for (
unsigned int y = 0; y < rows; ++y)
140 unsigned int position = y + (
x * rows);
141 U value = pixelData[position];
142 tempoBuffer[position*3] =
static_cast< T
>((redLookup[value]/(double)0xffff)*256);
143 tempoBuffer[position*3+1] =
static_cast< T
>((greenLookup[value]/(double)0xffff)*256);
144 tempoBuffer[position*3+2] =
static_cast< T
>((blueLookup[value]/(double)0xffff)*256);
static FWDCMTKIO_API void registerCodecs()
Load DICOM codec.
base class for BufferObject Lock
LockBase< T >::BufferType getBuffer() const
Returns BufferObject's buffer pointer.
static T * createInstanceBuffer(unsigned int rows, unsigned int columns, const ::fwMemory::BufferObject::sptr &instance, const T *redLookup, const T *greenLookup, const T *blueLookup)
Create an instance buffer according to the image type. The template T is used to determine color form...
static FWDCMTKIO_API void cleanup()
Clean up codec register.
fwDcmtkIO contains classes used to pull Dicom images from a pacs using dcmtk library.
static void * createInstanceBuffer(unsigned int rows, unsigned int columns, const ::fwMemory::BufferObject::sptr &instance, const T *redLookup, const T *greenLookup, const T *blueLookup, unsigned short pixelValueBitsAllocated)
Create an instance buffer according to the image type. The template T is used to determine color form...
#define OSLM_WARN_IF(message, cond)
This class is used to read the buffer of a DICOM image in LAZY mode when a pixel lookup must be perfo...