]> Creatis software - gdcm.git/commitdiff
Unnormalized 4th dimension is now dealt with.
authorjpr <jpr>
Wed, 29 Mar 2006 16:09:48 +0000 (16:09 +0000)
committerjpr <jpr>
Wed, 29 Mar 2006 16:09:48 +0000 (16:09 +0000)
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!

src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmPixelReadConvert.cxx
src/gdcmPixelReadConvert.h
src/gdcmRLEFramesInfo.cxx
src/gdcmRLEFramesInfo.h

index ad26ffde02c88b4a5c24a5dd8174fcfb385b92fd..7e7be8e5a5b93d2823e73fb440c20e264f622466 100644 (file)
@@ -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;
index de75a809a0de89e285a799ec2ae4120154f70743..86bf7c61024bd7f8b1db7b771cafb32aac522345 100644 (file)
@@ -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
 
 #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;         }
 
index 343534faba3db1c4e10e4316396f0af258d01c6a..32a8f81dfa4bb3d4573e4f0c14ae45964f527d99 100644 (file)
@@ -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 )
index 368b024830adf825326f50f26b08c455df9e5555..196b96492688b9de2776c9fb3de66591cabbf471 100644 (file)
@@ -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;
index de833c093864fdf23d66db85d4fec10c268c0d66..a4d37edd4e892f47825c29468066c015371cb85e 100644 (file)
@@ -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
index c4f44ddbc06043707517ddd2fb9c4ae320389b72..d4280bd2b665a4dbf7042df01cc1f5d20d7f26c9 100644 (file)
@@ -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);