From 4885f768a14f9f2e2ee3b3f58e5828b2b2962e17 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 29 Aug 2007 08:13:40 +0000 Subject: [PATCH] Don't convert gray pixels+LUT to RBG pixels before compression Replace tested->GetImageData() by tested->GetImageDataRaw() --- Example/WriteDicomAsJPEG.cxx | 18 ++++++++++-------- Example/WriteDicomAsJPEG2000.cxx | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Example/WriteDicomAsJPEG.cxx b/Example/WriteDicomAsJPEG.cxx index 9300c730..b8d52fbc 100644 --- a/Example/WriteDicomAsJPEG.cxx +++ b/Example/WriteDicomAsJPEG.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomAsJPEG.cxx,v $ Language: C++ - Date: $Date: 2007/08/28 16:49:04 $ - Version: $Revision: 1.19 $ + Date: $Date: 2007/08/29 08:13:40 $ + Version: $Revision: 1.20 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,12 +57,13 @@ int main(int argc, char *argv[]) //tested->Print( std::cout ); int samplesPerPixel = f->GetSamplesPerPixel(); - size_t testedDataSize = tested->GetImageDataSize(); - uint8_t *testedImageData = tested->GetImageData(); + size_t testedDataSize = tested->GetImageDataRawSize(); // Raw : Don't convert gray pixels+LUT to RBG pixels + uint8_t *testedImageData = tested->GetImageDataRaw(); - if( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) + if( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) { tested->Print( std::cout ); - + std::cout << "-------------------------------------------------------------------------------" << std::endl; + } // Step 1 : Create the header of the new file GDCM_NAME_SPACE::File *fileToBuild = GDCM_NAME_SPACE::File::New(); std::ostringstream str; @@ -145,9 +146,10 @@ int main(int argc, char *argv[]) // Consider that pixels are unmodified fileH->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE); - + std::cerr << "xsize " << xsize << " ysize " << ysize << " zsize " << zsize << " samplesPerPixel " << samplesPerPixel + << " bitsallocated " << bitsallocated << std::endl; std::cerr << "size " << size << " testedDataSize " << testedDataSize << - std::endl; + std::endl; assert(abs (size-testedDataSize) <= 1 ); fileH->SetWriteTypeToJPEG( ); //fileH->SetImageData(testedImageData, testedDataSize); diff --git a/Example/WriteDicomAsJPEG2000.cxx b/Example/WriteDicomAsJPEG2000.cxx index 613f382c..f66c7c30 100644 --- a/Example/WriteDicomAsJPEG2000.cxx +++ b/Example/WriteDicomAsJPEG2000.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomAsJPEG2000.cxx,v $ Language: C++ - Date: $Date: 2007/08/28 16:51:54 $ - Version: $Revision: 1.9 $ + Date: $Date: 2007/08/29 08:13:40 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,12 +57,13 @@ int main(int argc, char *argv[]) //tested->Print( std::cout ); int samplesPerPixel = f->GetSamplesPerPixel(); - size_t testedDataSize = tested->GetImageDataSize(); - uint8_t *testedImageData = tested->GetImageData(); + size_t testedDataSize = tested->GetImageDataRawSize(); // Raw : Don't convert gray pixels+LUT to RBG pixels + uint8_t *testedImageData = tested->GetImageDataRaw(); - if( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) + if( GDCM_NAME_SPACE::Debug::GetDebugFlag() ) { tested->Print( std::cout ); - + std::cout << "-------------------------------------------------------------------------------" << std::endl; + } // Step 1 : Create the header of the new file GDCM_NAME_SPACE::File *fileToBuild = GDCM_NAME_SPACE::File::New(); std::ostringstream str; @@ -145,9 +146,10 @@ int main(int argc, char *argv[]) // Consider that pixels are unmodified fileH->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE); - + std::cerr << "xsize " << xsize << " ysize " << ysize << " zsize " << zsize << " samplesPerPixel " << samplesPerPixel + << " bitsallocated " << bitsallocated << std::endl; std::cerr << "size " << size << " testedDataSize " << testedDataSize << - std::endl; + std::endl; assert(abs (size-testedDataSize) <= 1 ); fileH->SetWriteTypeToJPEG2000( ); //fileH->SetImageData(testedImageData, testedDataSize); -- 2.45.1