Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.cxx,v $
Language: C++
- Date: $Date: 2005/01/21 11:40:55 $
- Version: $Revision: 1.31 $
+ Date: $Date: 2005/01/26 11:42:02 $
+ 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
/**
* \brief Implementation of the RLE decoding algorithm for decompressing
* a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86]
- * @param subRaw Sub region of \ref Raw where the de
- * decoded fragment should be placed.
+ * @param subRaw Sub region of \ref Raw where the decoded fragment
+ * should be placed.
* @param fragmentSize The length of the binary fragment as found on the disk.
* @param RawSegmentSize The expected length of the fragment ONCE
* Raw.
++it )
{
// Loop on the fragments
- for( unsigned int k = 1; k <= (*it)->NumberFragments; k++ )
+ for( unsigned int k = 1; k <= (*it)->GetNumberOfFragments(); k++ )
{
- fp->seekg( (*it)->Offset[k] , std::ios::beg );
+ fp->seekg( (*it)->GetOffset(k) , std::ios::beg );
(void)ReadAndDecompressRLEFragment( subRaw,
- (*it)->Length[k],
+ (*it)->GetLength(k),
RawSegmentSize,
fp );
subRaw += RawSegmentSize;
}
/**
- * \brief Deal with endianity i.e. re-arange bytes inside the integer
+ * \brief Deal with endianness i.e. re-arange bytes inside the integer
*/
void PixelReadConvert::ConvertReorderEndianity()
{
bool PixelReadConvert::ReadAndDecompressJPEGFramesFromFile( std::ifstream *fp )
{
// Pointer to the Raw image
- uint8_t *localRaw = Raw;
+ //uint8_t *localRaw = Raw;
// Precompute the offset localRaw will be shifted with
int length = XSize * YSize * SamplesPerPixel;
int numberBytes = BitsAllocated / 8;
- // Loop on the fragment[s]
- for( JPEGFragmentsInfo::JPEGFragmentsList::iterator
- it = JPEGInfo->Fragments.begin();
- it != JPEGInfo->Fragments.end();
- ++it )
- {
- (*it)->DecompressJPEGFramesFromFile(fp, localRaw, BitsStored );
-
- // Advance to next free location in Raw
- // for next fragment decompression (if any)
-
- localRaw += length * numberBytes;
- }
+// // Loop on the fragment[s]
+// for( JPEGFragmentsInfo::JPEGFragmentsList::iterator
+// it = JPEGInfo->Fragments.begin();
+// it != JPEGInfo->Fragments.end();
+// ++it )
+// {
+// (*it)->DecompressJPEGFramesFromFile(fp, localRaw, BitsStored );
+//
+// // Advance to next free location in Raw
+// // for next fragment decompression (if any)
+//
+// localRaw += length * numberBytes;
+// }
+ JPEGInfo->DecompressJPEGFramesFromFile(fp, Raw, BitsStored, numberBytes, length );
return true;
}
(it != JPEGInfo->Fragments.end()) && (howManyRead < totalLength);
++it )
{
- fragmentLength += (*it)->Length;
+ fragmentLength += (*it)->GetLength();
if (howManyRead > fragmentLength) continue;
{
if ( IsJPEG2000 )
{
- fp->seekg( (*JPEGInfo->Fragments.begin())->Offset, std::ios::beg);
-// if ( ! gdcm_read_JPEG2000_file( fp,Raw ) )
+ gdcmVerboseMacro( "Sorry, JPEG2000 not yet taken into account" );
+ fp->seekg( (*JPEGInfo->Fragments.begin())->GetOffset(), std::ios::beg);
+// if ( ! gdcm_read_JPEG2000_file( fp,Raw ) )
+ gdcmVerboseMacro( "Wrong Blue LUT descriptor" );
+ return false;
+ }
+
+ if ( IsJPEGLS )
+ {
+ gdcmVerboseMacro( "Sorry, JPEG-LS not yet taken into account" );
+ fp->seekg( (*JPEGInfo->Fragments.begin())->GetOffset(), std::ios::beg);
+// if ( ! gdcm_read_JPEGLS_file( fp,Raw ) )
return false;
}
}
else if (JPEGInfo->Fragments.size() == (size_t)ZSize)
{
+ }
+// if ( ( ZSize == 1 ) && ( JPEGInfo->Fragments.size() > 1 ) )
+// {
+// // we have one frame split into several fragments
+// // we will pack those fragments into a single buffer and
+// // read from it
+// return ReadAndDecompressJPEGSingleFrameFragmentsFromFile( fp );
+// }
+// else if (JPEGInfo->Fragments.size() == (size_t)ZSize)
+// {
// suppose each fragment is a frame
return ReadAndDecompressJPEGFramesFromFile( fp );
- }
- else
- {
- // The dicom image contains frames containing fragments of images
- // a more complex algorithm :-)
- return ReadAndDecompressJPEGFragmentedFramesFromFile( fp );
- }
+// }
+// else
+// {
+// // The dicom image contains frames containing fragments of images
+// // a more complex algorithm :-)
+// return ReadAndDecompressJPEGFragmentedFramesFromFile( fp );
+// }
}
/**
}
/**
- * \brief Convert (Y plane, cB plane, cR plane) to RGB pixels
+ * \brief Convert (cY plane, cB plane, cR plane) to RGB pixels
* \warning Works on all the frames at a time
*/
void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels()
else if ( IsRaw )
{
// This problem can be found when some obvious informations are found
- // after the field containing the image datas. In this case, these
- // bad datas are added to the size of the image (in the PixelDataLength
+ // after the field containing the image data. In this case, these
+ // bad data are added to the size of the image (in the PixelDataLength
// variable). But RawSize is the right size of the image !
if( PixelDataLength != RawSize)
{
BitsAllocated = 16;
}
- // Number of "Bits Stored" defaulted to number of "Bits Allocated"
+ // Number of "Bits Stored", defaulted to number of "Bits Allocated"
// when absent from the header.
BitsStored = header->GetBitsStored();
if ( BitsStored == 0 )
BitsStored = BitsAllocated;
}
- // High Bit Position
+ // High Bit Position, defaulted to "Bits Allocated" - 1
HighBitPosition = header->GetHighBitPosition();
if ( HighBitPosition == 0 )
{
|| 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);
+
+ IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts);
+ IsJPEGLS = Global::GetTS()->IsJPEGLS(ts);
+ IsJPEGLossy = Global::GetTS()->IsJPEGLossy(ts);
+ IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts);
+ IsRLELossless = Global::GetTS()->IsRLELossless(ts);
+
PixelOffset = header->GetPixelOffset();
PixelDataLength = header->GetPixelAreaLength();
RLEInfo = header->GetRLEInfo();
if ( HasLUT )
{
// Just in case some access to a File element requires disk access.
- LutRedDescriptor = header->GetEntry( 0x0028, 0x1101 );
- LutGreenDescriptor = header->GetEntry( 0x0028, 0x1102 );
- LutBlueDescriptor = header->GetEntry( 0x0028, 0x1103 );
+ LutRedDescriptor = header->GetEntryValue( 0x0028, 0x1101 );
+ LutGreenDescriptor = header->GetEntryValue( 0x0028, 0x1102 );
+ LutBlueDescriptor = header->GetEntryValue( 0x0028, 0x1103 );
// Depending on the value of Document::MAX_SIZE_LOAD_ELEMENT_VALUE
// [ refer to invocation of Document::SetMaxSizeLoadEntry() in
}
}
- if ( IsJPEG2000 || IsJPEGLossless )
+ if ( IsJPEG2000 || IsJPEGLossless || IsJPEGLossy || IsJPEGLS )
{
if ( JPEGInfo )
{