From: jpr Date: Thu, 30 Aug 2007 10:16:58 +0000 (+0000) Subject: Show images whose pixels differ +/-1 after compression/decompression X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ba0bba00024f42c09d3defe2626536a9fbab8a04;p=gdcm.git Show images whose pixels differ +/-1 after compression/decompression --- diff --git a/Testing/TestReadWriteJPEGReadCompare.cxx b/Testing/TestReadWriteJPEGReadCompare.cxx index b89519a1..47e3702c 100755 --- a/Testing/TestReadWriteJPEGReadCompare.cxx +++ b/Testing/TestReadWriteJPEGReadCompare.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestReadWriteJPEGReadCompare.cxx,v $ Language: C++ - Date: $Date: 2007/08/29 15:56:41 $ - Version: $Revision: 1.4 $ + Date: $Date: 2007/08/30 10:16:58 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -30,7 +30,7 @@ const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10; int nb_of_success___; int nb_of_failure___; - +int nb_of_diffPM1___; static int CompareInternalJPEG(std::string const &filename, std::string const &output) { std::cout << "----------------------------------------------------------------------" << std::endl @@ -138,7 +138,10 @@ static int CompareInternalJPEG(std::string const &filename, std::string const &o // Test the data content if (memcmp(imageData, imageDataWritten, dataSizeFixed) !=0) - { + { + std::string PixelType = filehelper->GetFile()->GetPixelType(); + std::string ts = filehelper->GetFile()->GetTransferSyntax(); + unsigned int j =0; for(int i1=0; i1GetFile()->GetPixelType(); - std::string ts = filehelper->GetFile()->GetTransferSyntax(); - std::cout << " Failed" << std::endl << " pixel (" << PixelType @@ -166,7 +166,7 @@ static int CompareInternalJPEG(std::string const &filename, std::string const &o << " pixels differing (pos : original - written) :" << std::endl; - for(int i=0, j=0;i 2) { @@ -186,9 +186,40 @@ static int CompareInternalJPEG(std::string const &filename, std::string const &o nb_of_failure___++; return 1; } + else + { + std::cout << " some pixels" << std::endl + << " (" + << PixelType + << ") differ +/-1 (as expanded in memory)." + << std::endl + << " compression : " + << GDCM_NAME_SPACE::Global::GetTS()->GetValue(ts) << std::endl; + + std::cout << " list of the first " << MAX_NUMBER_OF_DIFFERENCE + << " pixels differing (pos : original - written) :" + << std::endl; + + for(int i=0, j=0; iDelete(); filehelper->Delete(); @@ -203,9 +234,10 @@ static int CompareInternalJPEG(std::string const &filename, std::string const &o int TestReadWriteJPEGReadCompare(int argc, char *argv[]) { int result = 0; - nb_of_success___ =0; - nb_of_failure___ =0; - + nb_of_success___ = 0; + nb_of_failure___ = 0; + nb_of_diffPM1___ = 0; + if (argc == 4) GDCM_NAME_SPACE::Debug::DebugOn(); @@ -247,8 +279,8 @@ int TestReadWriteJPEGReadCompare(int argc, char *argv[]) } } std::cout << "==================================" << std::endl; - std::cout << "nb of success " << nb_of_success___ << std::endl; - std::cout << "nb of failure " << nb_of_failure___ << std::endl; - + std::cout << "nb of success " << nb_of_success___ << std::endl; + std::cout << "nb of failure " << nb_of_failure___ << std::endl; + std::cout << "nb of diff+/-1 " << nb_of_diffPM1___ << std::endl; return result; }