00001 /* 00002 * 00003 * Copyright (C) 2007-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmjpls 00015 * 00016 * Author: Martin Willkomm, Uli Schlachter 00017 * 00018 * Purpose: codec classes for JPEG-LS encoders. 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:17:19 $ 00022 * CVS/RCS Revision: $Revision: 1.8 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCMJPLS_DJCODEC_H 00030 #define DCMJPLS_DJCODEC_H 00031 00032 #include "dcmtk/config/osconfig.h" 00033 #include "dcmtk/dcmdata/dccodec.h" /* for class DcmCodec */ 00034 #include "dcmtk/dcmdata/dcofsetl.h" /* for struct DcmOffsetList */ 00035 #include "dcmtk/ofstd/ofstring.h" /* for class OFString */ 00036 00037 class DJLSRepresentationParameter; 00038 class DJLSCodecParameter; 00039 class DicomImage; 00040 00047 class DJLSEncoderBase : public DcmCodec 00048 { 00049 public: 00050 00052 DJLSEncoderBase(); 00053 00055 virtual ~DJLSEncoderBase(); 00056 00067 virtual OFCondition decode( 00068 const DcmRepresentationParameter * fromRepParam, 00069 DcmPixelSequence * pixSeq, 00070 DcmPolymorphOBOW& uncompressedPixelData, 00071 const DcmCodecParameter * cp, 00072 const DcmStack& objStack) const; 00073 00099 virtual OFCondition decodeFrame( 00100 const DcmRepresentationParameter * fromParam, 00101 DcmPixelSequence * fromPixSeq, 00102 const DcmCodecParameter * cp, 00103 DcmItem *dataset, 00104 Uint32 frameNo, 00105 Uint32& startFragment, 00106 void *buffer, 00107 Uint32 bufSize, 00108 OFString& decompressedColorModel) const; 00109 00124 virtual OFCondition encode( 00125 const Uint16 * pixelData, 00126 const Uint32 length, 00127 const DcmRepresentationParameter * toRepParam, 00128 DcmPixelSequence * & pixSeq, 00129 const DcmCodecParameter *cp, 00130 DcmStack & objStack) const; 00131 00146 virtual OFCondition encode( 00147 const E_TransferSyntax fromRepType, 00148 const DcmRepresentationParameter * fromRepParam, 00149 DcmPixelSequence * fromPixSeq, 00150 const DcmRepresentationParameter * toRepParam, 00151 DcmPixelSequence * & toPixSeq, 00152 const DcmCodecParameter * cp, 00153 DcmStack & objStack) const; 00154 00162 virtual OFBool canChangeCoding( 00163 const E_TransferSyntax oldRepType, 00164 const E_TransferSyntax newRepType) const; 00165 00179 virtual OFCondition determineDecompressedColorModel( 00180 const DcmRepresentationParameter *fromParam, 00181 DcmPixelSequence *fromPixSeq, 00182 const DcmCodecParameter *cp, 00183 DcmItem *dataset, 00184 OFString &decompressedColorModel) const; 00185 00186 private: 00187 00192 virtual E_TransferSyntax supportedTransferSyntax() const = 0; 00193 00206 OFCondition losslessRawEncode( 00207 const Uint16 *pixelData, 00208 const Uint32 length, 00209 DcmItem *dataset, 00210 const DJLSRepresentationParameter *djrp, 00211 DcmPixelSequence * & pixSeq, 00212 const DJLSCodecParameter *djcp, 00213 double& compressionRatio) const; 00214 00228 OFCondition losslessCookedEncode( 00229 const Uint16 * pixelData, 00230 const Uint32 length, 00231 DcmItem *dataset, 00232 const DJLSRepresentationParameter *djrp, 00233 DcmPixelSequence * & pixSeq, 00234 const DJLSCodecParameter *djcp, 00235 double& compressionRatio, 00236 Uint16 nearLosslessDeviation) const; 00237 00243 OFCondition adjustOverlays( 00244 DcmItem *dataset, 00245 DicomImage& image) const; 00246 00254 OFCondition updateLossyCompressionRatio( 00255 DcmItem *dataset, 00256 double ratio) const; 00257 00266 OFCondition updateDerivationDescription( 00267 DcmItem *dataset, 00268 const DJLSRepresentationParameter *djrp, 00269 double ratio) const; 00270 00285 OFCondition compressRawFrame( 00286 const Uint8 *framePointer, 00287 Uint16 bitsAllocated, 00288 Uint16 columns, 00289 Uint16 rows, 00290 Uint16 samplesPerPixel, 00291 Uint16 planarConfiguration, 00292 const OFString& photometricInterpretation, 00293 DcmPixelSequence *pixelSequence, 00294 DcmOffsetList &offsetList, 00295 unsigned long &compressedSize, 00296 const DJLSCodecParameter *djcp) const; 00297 00309 OFCondition compressCookedFrame( 00310 DcmPixelSequence *pixelSequence, 00311 DicomImage *dimage, 00312 const OFString& photometricInterpretation, 00313 DcmOffsetList &offsetList, 00314 unsigned long &compressedSize, 00315 const DJLSCodecParameter *djcp, 00316 Uint32 frame, 00317 Uint16 nearLosslessDeviation) const; 00318 00328 OFCondition convertToUninterleaved( 00329 Uint8 *target, 00330 const Uint8 *source, 00331 Uint16 components, 00332 Uint32 width, 00333 Uint32 height, 00334 Uint16 bitsAllocated) const; 00335 00345 OFCondition convertToSampleInterleaved( 00346 Uint8 *target, 00347 const Uint8 *source, 00348 Uint16 components, 00349 Uint32 width, 00350 Uint32 height, 00351 Uint16 bitsAllocated) const; 00352 }; 00353 00354 00357 class DJLSLosslessEncoder : public DJLSEncoderBase 00358 { 00363 virtual E_TransferSyntax supportedTransferSyntax() const; 00364 }; 00365 00368 class DJLSNearLosslessEncoder : public DJLSEncoderBase 00369 { 00374 virtual E_TransferSyntax supportedTransferSyntax() const; 00375 }; 00376 00377 #endif 00378 00379 /* 00380 * CVS/RCS Log: 00381 * $Log: djcodece.h,v $ 00382 * Revision 1.8 2010-10-14 13:17:19 joergr 00383 * Updated copyright header. Added reference to COPYRIGHT file. 00384 * 00385 * Revision 1.7 2010-03-01 10:35:28 uli 00386 * Renamed include guards to avoid name clash with e.g. dcmjpeg. 00387 * 00388 * Revision 1.6 2010-02-26 10:54:41 uli 00389 * Fixed a compiler warning with MSVC about unsafe casts. 00390 * 00391 * Revision 1.5 2010-02-25 10:17:14 uli 00392 * Fix doxygen comments in a couple of places. 00393 * 00394 * Revision 1.4 2009-11-17 16:57:14 joergr 00395 * Added new method that allows for determining the color model of the 00396 * decompressed image. 00397 * 00398 * Revision 1.3 2009-10-07 13:16:47 uli 00399 * Switched to logging mechanism provided by the "new" oflog module. 00400 * 00401 * Revision 1.2 2009-07-31 09:14:52 meichel 00402 * Added codec parameter and command line options that allow to control 00403 * the interleave mode used in the JPEG-LS bitstream when compressing 00404 * color images. 00405 * 00406 * Revision 1.1 2009-07-29 14:46:46 meichel 00407 * Initial release of module dcmjpls, a JPEG-LS codec for DCMTK based on CharLS 00408 * 00409 * Revision 1.3 2008-05-29 10:54:05 meichel 00410 * Implemented new method DcmPixelData::getUncompressedFrame 00411 * that permits frame-wise access to compressed and uncompressed 00412 * objects without ever loading the complete object into main memory. 00413 * For this new method to work with compressed images, all classes derived from 00414 * DcmCodec need to implement a new method decodeFrame(). For now, only 00415 * dummy implementations returning an error code have been defined. 00416 * 00417 * Revision 1.2 2007/06/20 12:37:37 meichel 00418 * Completed implementation of encoder, which now supports lossless 00419 * "raw" and "cooked" and near-lossless "cooked" modes. 00420 * 00421 * Revision 1.1 2007/06/15 14:35:45 meichel 00422 * Renamed CMake project and include directory from dcmjpgls to dcmjpls 00423 * 00424 * Revision 1.4 2007/06/15 10:38:43 meichel 00425 * Further code clean-up. Encoder now produces valid offset tables if 00426 * a JPEG-LS frame size an odd number of bytes. 00427 * 00428 * Revision 1.3 2007/06/14 12:36:14 meichel 00429 * Further code clean-up. Updated doxygen comments. 00430 * 00431 * Revision 1.2 2007/06/13 16:41:07 meichel 00432 * Code clean-up and removal of dead code 00433 * 00434 * 00435 */