]> Creatis software - gdcm.git/commitdiff
Temporary modif for vtk reading of illegal 'DICOM FD' (64 bits 'double' pixels)
authorjpr <jpr>
Tue, 3 Nov 2009 14:05:23 +0000 (14:05 +0000)
committerjpr <jpr>
Tue, 3 Nov 2009 14:05:23 +0000 (14:05 +0000)
vtk/CMakeLists.txt
vtk/vtkGdcmReader.cxx
vtk/vtkGdcmReader.h
vtk/vtkgdcmViewer.cxx
vtk/vtkgdcmViewer2.cxx

index 9d50b42e80eb2fb002889ad1474427b67f32fcae..89f0eb6e084bd8ec7fc18cf6506476512c200eec 100644 (file)
@@ -3,6 +3,13 @@
 # Rebuild gdcm whenever a file starting with vtk* is modified
 INCLUDE_REGULAR_EXPRESSION("^vtk.*$")
 
+
+     if(COMMAND cmake_policy)
+       cmake_policy(SET CMP0003 NEW)
+     endif(COMMAND cmake_policy)
+
+
+
 #-----------------------------------------------------------------------------
 # Include the VTK library
 INCLUDE(${VTK_USE_FILE})
@@ -70,6 +77,14 @@ SET(vtkgdcmViewer_SOURCES
   vtkgdcmViewer.cxx
 )
 
+SET(vtkJPEGViewer_SOURCES
+  vtkJPEGViewer.cxx
+)
+
+SET(vtkJPEGViewer2_SOURCES
+  vtkJPEGViewer2.cxx
+)
+
 # let's do some APPLE/WIN32 magic here
 #IF(WIN32)
 #  SET(GUI_EXECUTABLE WIN32)
@@ -89,16 +104,30 @@ TARGET_LINK_LIBRARIES(vtkgdcmViewer
   vtkgdcm
   vtkRendering
 )
+
+ADD_EXECUTABLE(vtkJPEGViewer ${GUI_EXECUTABLE} ${vtkJPEGViewer_SOURCES})
+TARGET_LINK_LIBRARIES( vtkJPEGViewer
+  vtkRendering
+)
+
+ADD_EXECUTABLE(vtkJPEGViewer2 ${GUI_EXECUTABLE} ${vtkJPEGViewer2_SOURCES})
+TARGET_LINK_LIBRARIES( vtkJPEGViewer2
+  vtkgdcm
+  vtkRendering
+)
+
 ADD_EXECUTABLE(vtkgdcmViewer2 ${GUI_EXECUTABLE} vtkgdcmViewer2.cxx)
 TARGET_LINK_LIBRARIES(vtkgdcmViewer2
   vtkgdcm
   vtkRendering
 )
+
 ADD_EXECUTABLE(vtkgdcmSerieViewer ${GUI_EXECUTABLE} vtkgdcmSerieViewer.cxx)
 TARGET_LINK_LIBRARIES(vtkgdcmSerieViewer
   vtkgdcm
   vtkRendering
 )
+
 ADD_EXECUTABLE(vtkgdcmSerieViewer2 ${GUI_EXECUTABLE} vtkgdcmSerieViewer2.cxx)
 TARGET_LINK_LIBRARIES(vtkgdcmSerieViewer2
   vtkgdcm
@@ -110,15 +139,18 @@ TARGET_LINK_LIBRARIES(vtkgdcmSerieViewer2
 SET(vtkWriteDicom_SOURCES
   vtkWriteDicom.cxx
 )
+
 SET(vtkWriteDicomExtended_SOURCES
   vtkWriteDicomExtended.cxx  
 )
+
 ADD_EXECUTABLE(vtkWriteDicom ${vtkWriteDicom_SOURCES})
 TARGET_LINK_LIBRARIES(vtkWriteDicom
   vtkgdcm
   vtkIO
   vtkRendering
 )
+
 ADD_EXECUTABLE(vtkWriteDicomExtended ${vtkWriteDicomExtended_SOURCES})
 TARGET_LINK_LIBRARIES(vtkWriteDicomExtended
   vtkgdcm
@@ -135,7 +167,11 @@ ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
 IF(NOT GDCM_INSTALL_NO_LIBRARIES)
   INSTALL_TARGETS(${GDCM_INSTALL_LIB_DIR} vtkgdcm)
   INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkgdcmViewer)
-  INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkgdcmViewer2)
+  INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkgdcmViewer)
+  
+ # INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkJPEGViewer)
+ # INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkJPEGViewer2)
+      
   INSTALL_TARGETS(${GDCM_INSTALL_BIN_DIR} vtkgdcmSerieViewer)
 ENDIF(NOT GDCM_INSTALL_NO_LIBRARIES)
 
index 91bc6b408223892c69e9df85c0e08e09c271f82f..769d561d7ba053a171e5b5fa545bc6100b7f264c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/04/18 14:42:51 $
-  Version:   $Revision: 1.95 $
+  Date:      $Date: 2009/11/03 14:05:23 $
+  Version:   $Revision: 1.96 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -92,7 +92,7 @@
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.95 $")
+vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.96 $")
 vtkStandardNewMacro(vtkGdcmReader)
 
 //-----------------------------------------------------------------------------
@@ -282,7 +282,7 @@ void vtkGdcmReader::ExecuteInformation()
          vtkDebugMacro(<< "32 bits signed image");
          this->SetDataScalarTypeToInt();
       }
-      else if ( ImageType == "FD" )
+      else if ( ImageType == "FD" )  // This is not genuine DICOM, but so usefull
       {
          vtkDebugMacro(<< "64 bits Double image");
          this->SetDataScalarTypeToDouble();
@@ -513,11 +513,12 @@ void vtkGdcmReader::LoadFileInformation()
       type = file->GetPixelType();
       if (   (type !=  "8U") && (type !=  "8S")
           && (type != "16U") && (type != "16S")
-          && (type != "32U") && (type != "32S") )
+          && (type != "32U") && (type != "32S")
+          && (type != "FD")  )  // Not so sure this one is kosher
       {
          vtkErrorMacro(<< "Bad File Type for file " << filename->c_str() << "\n"
                        << "   File type found : " << type.c_str() 
-                       << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
+                       << " (might be 8U, 8S, 16U, 16S, 32U, 32S, FD) \n"
                        << "   Removing this file from read files");
          file->Delete();
          file=NULL;
@@ -860,9 +861,9 @@ void vtkGdcmReader::LoadImageInMemory(
       //if (this->GetFlipY())
          src  = (unsigned char*)fileH->GetImageData();
       //else
+      // very strange, but it doesn't work (I have to memcpy the pixels ?!?)
       //   dest  = (unsigned char*)fileH->GetImageData();        
-   } 
-
+   }
 
 if (this->GetFlipY()) {
    unsigned char *dst = dest + planeSize - lineSize;
@@ -885,7 +886,7 @@ if (this->GetFlipY()) {
       dst += 2 * planeSize;
    }
 }
-else
+else // we don't flip (upside down) the image
 {
   memcpy((void*)dest, (void*)src,  numPlanes * numLines * lineSize);
 }
index 928013a772bf85fc050f587dcae4f7680a15bd9d..864ea886afcb3d3d48406e401e420168a2996e26 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.h,v $
   Language:  C++
-  Date:      $Date: 2009/04/18 14:42:51 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2009/11/03 14:05:23 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -73,11 +73,17 @@ public:
    vtkSetMacro(KeepOverlays, bool);
    vtkGetMacro(KeepOverlays, bool);
    vtkBooleanMacro(KeepOverlays, bool);
-   
-   vtkSetMacro(FlipY, bool);
-   vtkGetMacro(FlipY, bool);
-   vtkBooleanMacro(FlipY, bool);   
-
+//  Implementation note: when FileLowerLeft (gdcm2) is set to on the image is not flipped
+// upside down as VTK would expect, use this option only if you know what you are doing.   
+  // vtkSetMacro(FileLowerLeft, bool);
+  // vtkGetMacro(FileLowerLeft, bool);
+  // vtkBooleanMacro(FileLowerLeft, bool);
+     
+  vtkSetMacro(FlipY, bool);
+  vtkGetMacro(FlipY, bool);
+  vtkBooleanMacro(FlipY, bool);
+     
    vtkGetObjectMacro(LookupTable, vtkLookupTable);
 
 // FIXME : HOW to doxygen a VTK macro?
@@ -191,8 +197,8 @@ private:
    
    bool KeepOverlays;
    
+  // bool FileLowerLeft;
    bool FlipY;
-   
    /// Pointer to a user suplied function to allow modification of pixel order
    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
 
index 0c0029b7906242e9d03e20352aff78d374ee7985..95da0fa0faf98538d2882e3246124ffd01376156 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkgdcmViewer.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/09/18 07:54:30 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2009/11/03 14:05:23 $
+  Version:   $Revision: 1.32 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -96,6 +96,18 @@ int main(int argc, char *argv[])
    reader->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOWSEQ);  
    reader->Update();
 
+
+
+std::cout << "[0][0]==========" <<
+reader->GetOutput()->GetScalarComponentAsFloat(0,0,0,0) <<
+"===================="
+<< std::endl;
+std::cout << "[127][127]==========" <<
+reader->GetOutput()->GetScalarComponentAsFloat(0,127,0,0) <<
+"===================="
+<< std::endl;
+
+
    //print debug info:
    reader->GetOutput()->Print( cout );
 
@@ -143,12 +155,22 @@ int main(int argc, char *argv[])
    iren->Initialize();
    iren->Start();
 
-   //if you wish you can export dicom to a vtk file  
+   //if you wish you can export dicom to a vtk file
    vtkStructuredPointsWriter *writer = vtkStructuredPointsWriter::New();
    writer->SetInput( reader->GetOutput());
    writer->SetFileName( "foo.vtk" );
    writer->SetFileTypeToBinary();
    //writer->Write();
+   
+std::cout << "==========" << std::endl;
+   
+std::cout << "==========" <<
+reader->GetOutput()->GetScalarComponentAsFloat(0,0,0,0) <<
+"===================="
+<< std::endl;
+     
+   
 
    reader->Delete();
    iren->Delete();
index b840ea1cd471f390c95c2a7b3bac67deda703ce1..a263cfd7c3491c5e2134dd6d0f53e1feead2c9b0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkgdcmViewer2.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/04/18 14:42:51 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2009/11/03 14:05:23 $
+  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
@@ -113,6 +113,7 @@ public:
 #endif
 };
 
+// --------------------------------------------------------------------------------
 
 int main(int argc, char *argv[])
 {