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
}
/**
- * \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()
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 ).
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
std::string GetPixelType();
bool IsSignedPixelData();
bool IsMonochrome();
+ bool IsMonochrome1();
bool IsPaletteColor();
bool IsYBRFull();
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
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:
//// Third stage: twigle the bytes and bits.
ConvertReorderEndianity();
ConvertReArrangeBits();
+ ConvertFixGreyLevels();
ConvertHandleColor();
return true;
}
}
+
+
+/**
+ * \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<RawSize; i++)
+ {
+ *deb = 255 - *deb;
+ deb++;
+ }
+ return;
+ }
+
+ if ( BitsAllocated == 16 )
+ {
+ uint16_t mask =1;
+ int bitStored = 12;
+ for (i=0; i<BitsStored-1; i++)
+ {
+ mask = (mask << 1) +1; // will be fff when BitStored=12
+ }
+
+ uint16_t *deb = (uint16_t *)Raw;
+ for (i=0; i<RawSize/2; i++)
+ {
+ *deb = mask - *deb;
+ deb++;
+ }
+ return;
+ }
+}
+
+
/**
* \brief Re-arrange the bits within the bytes.
* @return Boolean
Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.h,v $
Language: C++
- Date: $Date: 2005/02/03 10:03:07 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2005/02/15 18:12:35 $
+ Version: $Revision: 1.19 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void ConvertSwapZone();
void ConvertReorderEndianity();
bool ConvertReArrangeBits() throw ( FormatError );
+ void ConvertFixGreyLevels();
void ConvertRGBPlanesToRGBPixels();
void ConvertYcBcRPlanesToRGBPixels();
void ConvertHandleColor();
// For handling color stage
int PlanarConfiguration;
bool IsMonochrome;
+ bool IsMonochrome1;
bool IsPaletteColor;
bool IsYBRFull;
bool HasLUT;