From: jpr Date: Tue, 15 Feb 2005 18:12:34 +0000 (+0000) Subject: Taking into account the difference between MONOCHROME1 (low values = bright) X-Git-Tag: Version1.2.bp~880 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=da317a4e58595a638ab541c74fa8e5e8608819d3;p=gdcm.git Taking into account the difference between MONOCHROME1 (low values = bright) and MONOCHROME2 (low values = dark) --- diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 94f5ca5b..a9638f57 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/02/10 20:53:23 $ - Version: $Revision: 1.223 $ + Date: $Date: 2005/02/15 18:12:34 $ + Version: $Revision: 1.224 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -847,8 +847,8 @@ bool File::IsSignedPixelData() } /** - * \brief Check whether this a monochrome picture or not by accessing - * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). + * \brief Check whether this a monochrome picture (gray levels) or not, + * using "Photometric Interpretation" tag (0x0028,0x0004). * @return true when "MONOCHROME1" or "MONOCHROME2". False otherwise. */ bool File::IsMonochrome() @@ -866,6 +866,25 @@ bool File::IsMonochrome() return false; } +/** + * \brief Check whether this a MONOCHROME1 picture (high values = dark) + * or not using "Photometric Interpretation" tag (0x0028,0x0004). + * @return true when "MONOCHROME1" . False otherwise. + */ +bool File::IsMonochrome1() +{ + const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 ); + if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") ) + { + return true; + } + if ( PhotometricInterp == GDCM_UNFOUND ) + { + gdcmWarningMacro( "Not found : Photometric Interpretation (0028,0004)"); + } + return false; +} + /** * \brief Check whether this a "PALETTE COLOR" picture or not by accessing * the "Photometric Interpretation" tag ( 0x0028, 0x0004 ). diff --git a/src/gdcmFile.h b/src/gdcmFile.h index dd48d1c5..b0dabaf9 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2005/02/06 14:39:35 $ - Version: $Revision: 1.103 $ + Date: $Date: 2005/02/15 18:12:35 $ + Version: $Revision: 1.104 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -129,6 +129,7 @@ public: std::string GetPixelType(); bool IsSignedPixelData(); bool IsMonochrome(); + bool IsMonochrome1(); bool IsPaletteColor(); bool IsYBRFull(); diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 78075ab2..1d59ff9a 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/02/05 01:37:09 $ - Version: $Revision: 1.49 $ + Date: $Date: 2005/02/15 18:12:35 $ + Version: $Revision: 1.50 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -123,13 +123,15 @@ void PixelReadConvert::GrabInformationsFromFile( File *file ) PixelOffset = file->GetPixelOffset(); PixelDataLength = file->GetPixelAreaLength(); - RLEInfo = file->GetRLEInfo(); - JPEGInfo = file->GetJPEGInfo(); + RLEInfo = file->GetRLEInfo(); + JPEGInfo = file->GetJPEGInfo(); + + IsMonochrome = file->IsMonochrome(); + IsMonochrome1 = file->IsMonochrome1(); + IsPaletteColor = file->IsPaletteColor(); + IsYBRFull = file->IsYBRFull(); PlanarConfiguration = file->GetPlanarConfiguration(); - IsMonochrome = file->IsMonochrome(); - IsPaletteColor = file->IsPaletteColor(); - IsYBRFull = file->IsYBRFull(); ///////////////////////////////////////////////////////////////// // LUT section: @@ -262,6 +264,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) //// Third stage: twigle the bytes and bits. ConvertReorderEndianity(); ConvertReArrangeBits(); + ConvertFixGreyLevels(); ConvertHandleColor(); return true; @@ -641,6 +644,49 @@ void PixelReadConvert::ConvertReorderEndianity() } } + + +/** + * \brief Deal with Grey levels i.e. re-arange them + * to have low values = dark, high values = bright + */ +void PixelReadConvert::ConvertFixGreyLevels() +{ + if (!IsMonochrome1) + return; + + int i; // to please M$VC6 + if ( BitsAllocated == 8 ) + { + uint8_t *deb = (uint8_t *)Raw; + for (i=0; i