From: jpr Date: Wed, 29 Mar 2006 16:09:48 +0000 (+0000) Subject: Unnormalized 4th dimension is now dealt with. X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=2532a8e86e06d379d58b2fdda8e2413641d0a5f0;p=gdcm.git Unnormalized 4th dimension is now dealt with. User tells gdcm *where* it is. File::SetFourthDimensionLocation(groupNb, elementNb); After Load(), he may use int File::GetTSize(); As a proof of concept, PrintFile has one more option : 4Dloc=0x3001-0x1001, for instance. One can see pixel size is now computed properly. (VTK stuff is still missing) --> Later! --- diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index ad26ffde..7e7be8e5 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2006/03/13 14:44:07 $ - Version: $Revision: 1.97 $ + Date: $Date: 2006/03/29 16:09:48 $ + Version: $Revision: 1.98 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -798,6 +798,7 @@ bool FileHelper::CheckWriteIntegrity() size_t decSize = FileInternal->GetXSize() * FileInternal->GetYSize() * FileInternal->GetZSize() + * FileInternal->GetTSize() * FileInternal->GetSamplesPerPixel() * ( numberBitsAllocated / 8 ); size_t rgbSize = decSize; diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index de75a809..86bf7c61 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.h,v $ Language: C++ - Date: $Date: 2006/03/01 15:32:52 $ - Version: $Revision: 1.40 $ + Date: $Date: 2006/03/29 16:09:48 $ + Version: $Revision: 1.41 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,11 +21,11 @@ #include "gdcmDebug.h" #include "gdcmRefCounter.h" - +#include "gdcmFile.h" namespace gdcm { -class File; +//class File; class DataEntry; class SeqEntry; class PixelReadConvert; @@ -116,7 +116,11 @@ public: /// (as opposed to 'Grey pixels + Palettes color') void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); } /// \brief Sets the Write Mode ( ) - void SetWriteMode(FileMode mode) { WriteMode = mode; } + void SetWriteMode(FileMode mode) { + WriteMode = mode; + // Deal with Samples per Pixel + //if (mode == WMODE_RGB) FileInternal->InsertEntryString("3",0x0028,0x0002); + } /// \brief Gets the Write Mode ( ) FileMode GetWriteMode() { return WriteMode; } diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 343534fa..32a8f81d 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:14 $ - Version: $Revision: 1.110 $ + Date: $Date: 2006/03/29 16:09:48 $ + Version: $Revision: 1.111 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -115,6 +115,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file, XSize = file->GetXSize(); YSize = file->GetYSize(); ZSize = file->GetZSize(); + TSize = file->GetTSize(); SamplesPerPixel = file->GetSamplesPerPixel(); //PixelSize = file->GetPixelSize(); Useless PixelSign = file->IsSignedPixelData(); @@ -326,7 +327,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) else if ( IsRLELossless ) { if ( ! RLEInfo->DecompressRLEFile - ( fp, Raw, XSize, YSize, ZSize, BitsAllocated ) ) + ( fp, Raw, XSize, YSize, ZSize, TSize, BitsAllocated ) ) { gdcmWarningMacro( "RLE decompressor failed." ); return false; @@ -448,7 +449,8 @@ bool PixelReadConvert::BuildRGBImage() void PixelReadConvert::ReadAndDecompress12BitsTo16Bits( std::ifstream *fp ) throw ( FormatError ) { - int nbPixels = XSize * YSize; + /// \todo Fix the 3D, 4D pb + int nbPixels = XSize * YSize * TSize; uint16_t *localDecompres = (uint16_t*)Raw; for( int p = 0; p < nbPixels; p += 2 ) @@ -584,7 +586,7 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp ) // make sure this is the right JPEG compression assert( !IsJPEGLS || !IsJPEG2000 ); // Precompute the offset localRaw will be shifted with - int length = XSize * YSize * SamplesPerPixel; + int length = XSize * YSize * ZSize * SamplesPerPixel; int numberBytes = BitsAllocated / 8; JPEGInfo->DecompressFromFile(fp, Raw, BitsStored, numberBytes, length ); @@ -1191,7 +1193,9 @@ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() // ftp://medical.nema.org/medical/dicom/final/sup61_ft.pdf // and be *very* affraid // - int l = XSize * YSize; + + /// \todo : find an example to see how 3rd dim and 4th dim work together + int l = XSize * YSize * TSize; int nbFrames = ZSize; uint8_t *a = copyRaw + 0; @@ -1331,7 +1335,7 @@ void PixelReadConvert::ComputeRawAndRGBSizes() bitsAllocated = 16; } - RawSize = XSize * YSize * ZSize + RawSize = XSize * YSize * ZSize * TSize * ( bitsAllocated / 8 ) * SamplesPerPixel; if ( HasLUT ) diff --git a/src/gdcmPixelReadConvert.h b/src/gdcmPixelReadConvert.h index 368b0248..196b9649 100644 --- a/src/gdcmPixelReadConvert.h +++ b/src/gdcmPixelReadConvert.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.h,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:15 $ - Version: $Revision: 1.29 $ + Date: $Date: 2006/03/29 16:09:48 $ + Version: $Revision: 1.30 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -130,6 +130,7 @@ private: int XSize; int YSize; int ZSize; + int TSize; int BitsAllocated; int BitsStored; int HighBitPosition; diff --git a/src/gdcmRLEFramesInfo.cxx b/src/gdcmRLEFramesInfo.cxx index de833c09..a4d37edd 100644 --- a/src/gdcmRLEFramesInfo.cxx +++ b/src/gdcmRLEFramesInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFramesInfo.cxx,v $ Language: C++ - Date: $Date: 2006/01/27 10:01:34 $ - Version: $Revision: 1.20 $ + Date: $Date: 2006/03/29 16:09:48 $ + 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 @@ -71,15 +71,16 @@ RLEFrame *RLEFramesInfo::GetNextFrame() * @param xSize x Size * @param ySize y Size * @param zSize z Size + * @param tSize t Size * @param bitsAllocated Bits allocated * @return Boolean */ bool RLEFramesInfo::DecompressRLEFile( std::ifstream *fp , uint8_t *raw, int xSize, int ySize, int zSize, - int bitsAllocated ) + int tSize, int bitsAllocated ) { uint8_t *subRaw = raw; - long rawSegmentSize = xSize * ySize; + long rawSegmentSize = xSize * ySize * tSize; // Loop on the frame[s] for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it) @@ -90,7 +91,7 @@ bool RLEFramesInfo::DecompressRLEFile( std::ifstream *fp , uint8_t *raw, if ( bitsAllocated == 16 ) { // Try to deal with RLE 16 Bits - ConvertRLE16BitsFromRLE8Bits( raw, xSize, ySize, zSize ); + ConvertRLE16BitsFromRLE8Bits( raw, xSize, ySize, zSize, tSize ); } return true; @@ -103,13 +104,15 @@ bool RLEFramesInfo::DecompressRLEFile( std::ifstream *fp , uint8_t *raw, * @param raw raw * @param xSize x Size * @param ySize y Size + * @param tSize t Size * @param numberOfFrames number of frames * @return Boolean always true */ bool RLEFramesInfo::ConvertRLE16BitsFromRLE8Bits(uint8_t *raw, int xSize, - int ySize, int numberOfFrames) + int ySize, int tSize, + int numberOfFrames) { - size_t pixelNumber = xSize * ySize; + size_t pixelNumber = xSize * ySize * tSize; size_t rawSize = pixelNumber * numberOfFrames * 2; // We assumed Raw contains the decoded RLE pixels but as @@ -175,6 +178,8 @@ void RLEFramesInfo::Print( std::ostream &os, std::string indent ) << "Total number of Frames : " << Frames.size() << std::endl; int frameNumber = 0; + /// \todo : find an example, to know haow 3rd and 4th dimension + /// works together for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it) { os << indent diff --git a/src/gdcmRLEFramesInfo.h b/src/gdcmRLEFramesInfo.h index c4f44ddb..d4280bd2 100644 --- a/src/gdcmRLEFramesInfo.h +++ b/src/gdcmRLEFramesInfo.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmRLEFramesInfo.h,v $ Language: C++ - Date: $Date: 2006/02/16 20:06:15 $ - Version: $Revision: 1.21 $ + Date: $Date: 2006/03/29 16:09:48 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -49,9 +49,9 @@ private: ~RLEFramesInfo(); void Print( std::ostream &os = std::cout, std::string indent = "" ); bool DecompressRLEFile( std::ifstream *fp, uint8_t *subRaw, int xSize, - int ySize, int zSize, int bitsAllocated ); - bool ConvertRLE16BitsFromRLE8Bits( uint8_t *subRaw, int xSize, int ySize, - int numberOfFrames ); + int ySize, int zSize, int tSize, int bitsAllocated ); + bool ConvertRLE16BitsFromRLE8Bits( uint8_t *subRaw, int xSize, int ySize, + int tSize, int numberOfFrames); void AddFrame(RLEFrame *frame);