From: jpr Date: Tue, 3 Nov 2009 14:05:23 +0000 (+0000) Subject: Temporary modif for vtk reading of illegal 'DICOM FD' (64 bits 'double' pixels) X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=gdcm.git;a=commitdiff_plain;h=ca1e16227a30bd895c6acdc27244c838f0631c2e Temporary modif for vtk reading of illegal 'DICOM FD' (64 bits 'double' pixels) --- diff --git a/vtk/CMakeLists.txt b/vtk/CMakeLists.txt index 9d50b42e..89f0eb6e 100644 --- a/vtk/CMakeLists.txt +++ b/vtk/CMakeLists.txt @@ -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) diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 91bc6b40..769d561d 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -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 #include -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); } diff --git a/vtk/vtkGdcmReader.h b/vtk/vtkGdcmReader.h index 928013a7..864ea886 100644 --- a/vtk/vtkGdcmReader.h +++ b/vtk/vtkGdcmReader.h @@ -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; diff --git a/vtk/vtkgdcmViewer.cxx b/vtk/vtkgdcmViewer.cxx index 0c0029b7..95da0fa0 100644 --- a/vtk/vtkgdcmViewer.cxx +++ b/vtk/vtkgdcmViewer.cxx @@ -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(); diff --git a/vtk/vtkgdcmViewer2.cxx b/vtk/vtkgdcmViewer2.cxx index b840ea1c..a263cfd7 100644 --- a/vtk/vtkgdcmViewer2.cxx +++ b/vtk/vtkgdcmViewer2.cxx @@ -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[]) {