Program: gdcm
Module: $RCSfile: TestTS.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 14:39:03 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2005/01/11 16:44:42 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Unknown
std::cout << ts.IsTransferSyntax( "Unknown Transfer Syntax" ) << std::endl;
+ // Test JPEG test:
+ std::cout << "Test TS:" << std::endl;
+ std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.4.55") << std::endl;
+//if ( key == "1.2.840.10008.1.2.4.55"
+// || key == "1.2.840.10008.1.2.4.57"
+// || key == "1.2.840.10008.1.2.4.70" )
+ std::cout << ts.IsRLELossless( "1.2.840.10008.1.2.5") << std::endl;
+ std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl;
+ std::cout << ts.IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl;
+ std::cout << ts.IsJPEG( "1.2.840.10008.1.2.5") << std::endl;
+ std::cout << ts.IsEncapsulate( "1.2.840.10008.1.2.5") << std::endl;
+ std::cout << ts.GetSpecialTransferSyntax( ts.GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl;
+
return ts.GetValue( "" ) != gdcm::GDCM_UNFOUND;
}
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 11:37:13 $
- Version: $Revision: 1.173 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.174 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
-//-----------------------------------------------------------------------------
-static const char *TransferSyntaxStrings[] = {
- // Implicit VR Little Endian
- "1.2.840.10008.1.2",
- // Implicit VR Big Endian DLX (G.E Private)
- "1.2.840.113619.5.2",
- // Explicit VR Little Endian
- "1.2.840.10008.1.2.1",
- // Deflated Explicit VR Little Endian
- "1.2.840.10008.1.2.1.99",
- // Explicit VR Big Endian
- "1.2.840.10008.1.2.2",
- // JPEG Baseline (Process 1)
- "1.2.840.10008.1.2.4.50",
- // JPEG Extended (Process 2 & 4)
- "1.2.840.10008.1.2.4.51",
- // JPEG Extended (Process 3 & 5)
- "1.2.840.10008.1.2.4.52",
- // JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)
- "1.2.840.10008.1.2.4.53",
- // JPEG Full Progression, Non-Hierarchical (Process 10 & 12)
- "1.2.840.10008.1.2.4.55",
- // JPEG Lossless, Non-Hierarchical (Process 14)
- "1.2.840.10008.1.2.4.57",
- // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, [Selection Value 1])
- "1.2.840.10008.1.2.4.70",
- // JPEG 2000 Lossless
- "1.2.840.10008.1.2.4.90",
- // JPEG 2000
- "1.2.840.10008.1.2.4.91",
- // RLE Lossless
- "1.2.840.10008.1.2.5",
- // Unknown
- "Unknown Transfer Syntax"
-};
//-----------------------------------------------------------------------------
// Refer to Document::CheckSwap()
* value from disk when only parsing occured).
* @return The encountered Transfer Syntax of the current document.
*/
-TransferSyntaxType Document::GetTransferSyntax()
+std::string Document::GetTransferSyntax()
{
DocEntry *entry = GetDocEntry(0x0002, 0x0010);
if ( !entry )
{
- return UnknownTS;
+ return GDCM_UNKNOWN;
}
// The entry might be present but not loaded (parsing and loading
if ( transfer.length() == 0 )
{
// for brain damaged headers
- return UnknownTS;
+ return GDCM_UNKNOWN;
}
while ( !isdigit((unsigned char)transfer[transfer.length()-1]) )
{
transfer.erase(transfer.length()-1, 1);
}
- for (int i = 0; TransferSyntaxStrings[i] != NULL; i++)
- {
- if ( TransferSyntaxStrings[i] == transfer )
- {
- return TransferSyntaxType(i);
- }
- }
+ return transfer;
}
- return UnknownTS;
-}
-
-bool Document::IsJPEGLossless()
-{
- TransferSyntaxType r = GetTransferSyntax();
- return r == JPEGFullProgressionProcess10_12
- || r == JPEGLosslessProcess14
- || r == JPEGLosslessProcess14_1;
-}
-
-/**
- * \brief Determines if the Transfer Syntax was already encountered
- * and if it corresponds to a JPEG2000 one
- * @return True when JPEG2000 (Lossly or LossLess) found. False in all
- * other cases.
- */
-bool Document::IsJPEG2000()
-{
- TransferSyntaxType r = GetTransferSyntax();
- return r == JPEG2000Lossless || r == JPEG2000;
-}
-
-/**
- * \brief Determines if the Transfer Syntax corresponds to any form
- * of Jpeg encoded Pixel data.
- * @return True when any form of JPEG found. False otherwise.
- */
-bool Document::IsJPEG()
-{
- TransferSyntaxType r = GetTransferSyntax();
- return r == JPEGBaselineProcess1
- || r == JPEGExtendedProcess2_4
- || r == JPEGExtendedProcess3_5
- || r == JPEGSpectralSelectionProcess6_8
- || IsJPEGLossless()
- || IsJPEG2000();
-}
-
-/**
- * \brief Determines if the Transfer Syntax corresponds to encapsulated
- * of encoded Pixel Data (as opposed to native).
- * @return True when encapsulated. False when native.
- */
-bool Document::IsEncapsulate()
-{
- TransferSyntaxType r = GetTransferSyntax();
- return IsJPEG() || r == RLELossless;
+ return GDCM_UNKNOWN;
}
/**
return true;
}
-std::string Document::GetTransferSyntaxValue(TransferSyntaxType type)
-{
- return TransferSyntaxStrings[type];
-}
-
//-----------------------------------------------------------------------------
// Protected
if ( ( newDocEntry->GetGroup() == 0x7fe0 )
&& ( newDocEntry->GetElement() == 0x0010 ) )
{
- TransferSyntaxType ts = GetTransferSyntax();
- if ( ts == RLELossless )
+ std::string ts = GetTransferSyntax();
+ if ( Global::GetTS()->IsRLELossless(ts) )
{
long positionOnEntry = Fp->tellg();
Fp->seekg( newDocEntry->GetOffset(), std::ios::beg );
ComputeRLEInfo();
Fp->seekg( positionOnEntry, std::ios::beg );
}
- else if ( IsJPEG() )
+ else if ( Global::GetTS()->IsJPEG(ts) )
{
long positionOnEntry = Fp->tellg();
Fp->seekg( newDocEntry->GetOffset(), std::ios::beg );
// big endian and proceed...
if ( element == 0x0000 && length16 == 0x0400 )
{
- TransferSyntaxType ts = GetTransferSyntax();
- if ( ts != ExplicitVRBigEndian )
+ std::string ts = GetTransferSyntax();
+ if ( Global::GetTS()->GetSpecialTransferSyntax(ts) != TS::ExplicitVRBigEndian )
{
throw FormatError( "Document::FindDocEntryLength()",
" not explicit VR." );
*/
void Document::ComputeRLEInfo()
{
- TransferSyntaxType ts = GetTransferSyntax();
- if ( ts != RLELossless )
+ std::string ts = GetTransferSyntax();
+ if ( Global::GetTS()->IsRLELossless(ts) )
{
return;
}
void Document::ComputeJPEGFragmentInfo()
{
// If you need to, look for comments of ComputeRLEInfo().
- if ( ! IsJPEG() )
+ std::string ts = GetTransferSyntax();
+ if ( ! Global::GetTS()->IsJPEG(ts) )
{
return;
}
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2005/01/11 11:37:13 $
- Version: $Revision: 1.79 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.80 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class RLEFramesInfo;
class JPEGFragmentsInfo;
-enum TransferSyntaxType {
- ImplicitVRLittleEndian = 0,
- ImplicitVRLittleEndianDLXGE,
- ExplicitVRLittleEndian,
- DeflatedExplicitVRLittleEndian,
- ExplicitVRBigEndian,
- JPEGBaselineProcess1,
- JPEGExtendedProcess2_4,
- JPEGExtendedProcess3_5,
- JPEGSpectralSelectionProcess6_8,
- JPEGFullProgressionProcess10_12,
- JPEGLosslessProcess14,
- JPEGLosslessProcess14_1,
- JPEG2000Lossless,
- JPEG2000,
- RLELossless,
- UnknownTS
-};
-
//-----------------------------------------------------------------------------
/**
* \brief Derived by both Header and DicomDir
virtual bool IsReadable();
FileType GetFileType();
- TransferSyntaxType GetTransferSyntax();
+ std::string GetTransferSyntax();
- bool IsJPEGLossless();
- bool IsJPEG2000();
- bool IsJPEG();
- bool IsEncapsulate();
bool IsDicomV3();
RLEFramesInfo *GetRLEInfo() { return RLEInfo; }
void LoadDocEntrySafe(DocEntry *entry);
TagDocEntryHT *BuildFlatHashTable();
-// Divers
- static std::string GetTransferSyntaxValue(TransferSyntaxType type);
-
protected:
// Methods
// Constructor and destructor are protected to forbid end user
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 11:37:13 $
- Version: $Revision: 1.189 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.190 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmFile.h"
+#include "gdcmGlobal.h"
+#include "gdcmTS.h"
#include "gdcmDocument.h"
#include "gdcmDebug.h"
#include "gdcmUtil.h"
void File::SetWriteFileTypeToExplicitVR()
{
std::string ts = Util::DicomString(
- Document::GetTransferSyntaxValue(ExplicitVRLittleEndian).c_str() );
+ Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
ValEntry *tss = CopyValEntry(0x0002,0x0010);
tss->SetValue(ts);
void File::SetWriteFileTypeToImplicitVR()
{
std::string ts = Util::DicomString(
- Document::GetTransferSyntaxValue(ImplicitVRLittleEndian).c_str() );
+ Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
ValEntry *tss = CopyValEntry(0x0002,0x0010);
tss->SetValue(ts);
Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.cxx,v $
Language: C++
- Date: $Date: 2005/01/08 15:03:59 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.21 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDebug.h"
#include "gdcmHeader.h"
+#include "gdcmGlobal.h"
+#include "gdcmTS.h"
#include "gdcmPixelReadConvert.h"
#include "gdcmDocEntry.h"
#include "gdcmRLEFramesInfo.h"
PixelSize = header->GetPixelSize();
PixelSign = header->IsSignedPixelData();
SwapCode = header->GetSwapCode();
- TransferSyntaxType ts = header->GetTransferSyntax();
+ std::string ts = header->GetTransferSyntax();
IsRaw =
( ! header->IsDicomV3() )
- || ts == ImplicitVRLittleEndian
- || ts == ImplicitVRLittleEndianDLXGE
- || ts == ExplicitVRLittleEndian
- || ts == ExplicitVRBigEndian
- || ts == DeflatedExplicitVRLittleEndian;
- IsJPEG2000 = header->IsJPEG2000();
- IsJPEGLossless = header->IsJPEGLossless();
- IsRLELossless = ( ts == RLELossless );
+ || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian
+ || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndianDLXGE
+ || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian
+ || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian
+ || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian;
+ IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts);
+ IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts);
+ IsRLELossless = Global::GetTS()->IsRLELossless(ts);
PixelOffset = header->GetPixelOffset();
PixelDataLength = header->GetPixelAreaLength();
RLEInfo = header->GetRLEInfo();
Program: gdcm
Module: $RCSfile: gdcmTS.cxx,v $
Language: C++
- Date: $Date: 2005/01/11 00:37:41 $
- Version: $Revision: 1.34 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.35 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
+//-----------------------------------------------------------------------------
+static const char *SpecialStrings[] = {
+ // Implicit VR Little Endian
+ "1.2.840.10008.1.2",
+ // Implicit VR Big Endian DLX (G.E Private)
+ "1.2.840.113619.5.2",
+ // Explicit VR Little Endian
+ "1.2.840.10008.1.2.1",
+ // Deflated Explicit VR Little Endian
+ "1.2.840.10008.1.2.1.99",
+ // Explicit VR Big Endian
+ "1.2.840.10008.1.2.2",
+ // JPEG Baseline (Process 1)
+ "1.2.840.10008.1.2.4.50",
+ // JPEG Extended (Process 2 & 4)
+ "1.2.840.10008.1.2.4.51",
+ // JPEG Extended (Process 3 & 5)
+ "1.2.840.10008.1.2.4.52",
+ // JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)
+ "1.2.840.10008.1.2.4.53",
+ // JPEG Full Progression, Non-Hierarchical (Process 10 & 12)
+ "1.2.840.10008.1.2.4.55",
+ // JPEG Lossless, Non-Hierarchical (Process 14)
+ "1.2.840.10008.1.2.4.57",
+ // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, [Selection Value 1])
+ "1.2.840.10008.1.2.4.70",
+ // JPEG 2000 Lossless
+ "1.2.840.10008.1.2.4.90",
+ // JPEG 2000
+ "1.2.840.10008.1.2.4.91",
+ // RLE Lossless
+ "1.2.840.10008.1.2.5",
+ // Unknown
+ "Unknown Transfer Syntax"
+};
+
void FillDefaultTSDict(TSHT &ts);
//-----------------------------------------------------------------------------
// Constructor / Destructor
{
TSKey key;
TSAtr name;
-
+
while (!from.eof())
{
from >> key;
from >> std::ws;
std::getline(from, name);
-
+
if(key != "")
{
TsMap[key] = name;
bool TS::IsTransferSyntax(TSKey const &key)
{
- for (TSHT::const_iterator it = TsMap.begin(); it != TsMap.end(); ++it)
+ TSHT::const_iterator it = TsMap.find(key);
+ return it != TsMap.end();
+}
+
+bool TS::IsRLELossless(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[RLELossless] )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+bool TS::IsJPEGLossless(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[JPEGFullProgressionProcess10_12]
+ || key == SpecialStrings[JPEGLosslessProcess14]
+ || key == SpecialStrings[JPEGLosslessProcess14_1] )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+/**
+ * \brief Determines if the Transfer Syntax was already encountered
+ * and if it corresponds to a JPEG2000 one
+ * @return True when JPEG2000 (Lossly or LossLess) found. False in all
+ * other cases.
+ */
+bool TS::IsJPEG2000(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
{
- if( it->first == key ) return true;
+ if ( key == SpecialStrings[JPEG2000Lossless]
+ || key == SpecialStrings[JPEG2000] )
+ {
+ r = true;
+ }
}
+ return r;
+}
- return false;
+/**
+ * \brief Determines if the Transfer Syntax corresponds to any form
+ * of Jpeg encoded Pixel data.
+ * @return True when any form of JPEG found. False otherwise.
+ */
+bool TS::IsJPEG(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[JPEGBaselineProcess1]
+ || key == SpecialStrings[JPEGExtendedProcess2_4]
+ || key == SpecialStrings[JPEGExtendedProcess3_5]
+ || key == SpecialStrings[JPEGSpectralSelectionProcess6_8]
+ || IsJPEGLossless( key )
+ || IsJPEG2000( key ) )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+/**
+ * \brief Determines if the Transfer Syntax corresponds to encapsulated
+ * of encoded Pixel Data (as opposed to native).
+ * @return True when encapsulated. False when native.
+ */
+bool TS::IsEncapsulate(TSKey const &key)
+{
+ bool r = false;
+ // First check this is an actual transfer syntax
+ if( IsTransferSyntax(key) )
+ {
+ if ( key == SpecialStrings[RLELossless]
+ || IsJPEG(key) )
+ {
+ r = true;
+ }
+ }
+ return r;
+}
+
+TS::SpecialType TS::GetSpecialTransferSyntax(TSKey const &key)
+{
+ for (int i = 0; SpecialStrings[i] != NULL; i++)
+ {
+ if ( SpecialStrings[i] == key )
+ {
+ return SpecialType(i);
+ }
+ }
+
+ return UnknownTS;
+}
+
+const char* TS::GetSpecialTransferSyntax(SpecialType t)
+{
+ return SpecialStrings[t];
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmTS.h,v $
Language: C++
- Date: $Date: 2005/01/11 15:15:38 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2005/01/11 16:44:43 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
typedef std::string TSAtr;
typedef std::map<TSKey, TSAtr> TSHT; // Transfer Syntax Hash Table
+
//-----------------------------------------------------------------------------
/**
* \brief Container for dicom 'Transfer Syntax' Hash Table
*/
class GDCM_EXPORT TS
{
+public:
+enum SpecialType {
+ ImplicitVRLittleEndian = 0,
+ ImplicitVRLittleEndianDLXGE,
+ ExplicitVRLittleEndian,
+ DeflatedExplicitVRLittleEndian,
+ ExplicitVRBigEndian,
+ JPEGBaselineProcess1,
+ JPEGExtendedProcess2_4,
+ JPEGExtendedProcess3_5,
+ JPEGSpectralSelectionProcess6_8,
+ JPEGFullProgressionProcess10_12,
+ JPEGLosslessProcess14,
+ JPEGLosslessProcess14_1,
+ JPEG2000Lossless,
+ JPEG2000,
+ RLELossless,
+ UnknownTS
+};
+
public:
TS();
~TS();
int Count(TSKey const &key);
TSAtr const &GetValue(TSKey const &key);
bool IsTransferSyntax(TSKey const &key);
+ bool IsRLELossless(TSKey const &key);
+ bool IsJPEGLossless(TSKey const&key);
+ bool IsJPEG2000(TSKey const &key);
+ bool IsJPEG(TSKey const &key);
+ bool IsEncapsulate(TSKey const &key);
+
+ // This should be deprecated very soon
+ SpecialType GetSpecialTransferSyntax(TSKey const &key);
+ const char* GetSpecialTransferSyntax(SpecialType t);
private:
TSHT TsMap;