[Gdcm-hackers] gdcm-git:Grassroots DICOM branch release updated. 9f3df4f242d78a677678eb609d5ff76e9e
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mathieu M. <ma...@us...> - 2015-10-28 12:17:54
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Grassroots DICOM".
The branch, release has been updated
via 9f3df4f242d78a677678eb609d5ff76e9e49f271 (commit)
via 79fd37a0c0e6d26d6a752dea063f21d2ee916e7b (commit)
via d7d7e3b807f86beab35c7eedebd33379b0e799d6 (commit)
from 3ee1bec2ebdcd58b398c15a1faa76c17363387bd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceforge.net/p/gdcm/gdcm/ci/9f3df4f242d78a677678eb609d5ff76e9e49f271/
commit 9f3df4f242d78a677678eb609d5ff76e9e49f271
Author: Mathieu Malaterre <mat...@gm...>
Date: Wed Oct 28 13:17:01 2015 +0100
Work toward issue with VS DS and > 16 bytes ASCII
diff --git a/Source/DataStructureAndEncodingDefinition/gdcmElement.h b/Source/DataStructureAndEncodingDefinition/gdcmElement.h
index 545ff29..2edd8f9 100644
--- a/Source/DataStructureAndEncodingDefinition/gdcmElement.h
+++ b/Source/DataStructureAndEncodingDefinition/gdcmElement.h
@@ -263,6 +263,9 @@ public:
}
};
+#define VRDS16ILLEGAL
+
+#ifdef VRDS16ILLEGAL
template < typename Float >
std::string to_string ( Float data ) {
std::stringstream in;
@@ -277,6 +280,44 @@ std::string to_string ( Float data ) {
throw "Impossible Conversion"; // should not happen ...
}
}
+#else
+// http://stackoverflow.com/questions/32631178/writing-ieee-754-1985-double-as-ascii-on-a-limited-16-bytes-string
+static size_t shrink(char *fp_buffer) {
+ int lead, expo;
+ long long mant;
+ int n0, n1;
+ int n = sscanf(fp_buffer, "%d.%n%lld%ne%d", &lead, &n0, &mant, &n1, &expo);
+ assert(n == 3);
+ return sprintf(fp_buffer, "%d%0*llde%d", lead, n1 - n0, mant,
+ expo - (n1 - n0));
+}
+
+template < typename Float >
+static int x16printf(char *dest, size_t width, Float value) {
+ if (!std::isfinite(value)) return 1;
+
+ if (width < 5) return 2;
+ if (std::signbit(value)) {
+ value = -value;
+ strcpy(dest++, "-");
+ width--;
+ }
+ int precision = width - 2;
+ while (precision > 0) {
+ char buffer[width + 10];
+ // %.*e prints 1 digit, '.' and then `precision - 1` digits
+ snprintf(buffer, sizeof buffer, "%.*e", precision - 1, value);
+ size_t n = shrink(buffer);
+ if (n <= width) {
+ strcpy(dest, buffer);
+ return 0;
+ }
+ if (n > width + 1) precision -= n - width - 1;
+ else precision--;
+ }
+ return 3;
+}
+#endif
/* Writing VR::DS is not that easy after all */
// http://groups.google.com/group/comp.lang.c++/browse_thread/thread/69ccd26f000a0802
@@ -284,10 +325,21 @@ template<> inline void EncodingImplementation<VR::VRASCII>::Write(const float *
assert( data );
assert( length );
assert( _os );
+#ifdef VRDS16ILLEGAL
_os << to_string(data[0]);
+#else
+ char buf[16+1];
+ x16printf(buf, sizeof buf, data[0]);
+ _os << buf;
+#endif
for(unsigned long i=1; i<length; ++i) {
assert( _os );
+#ifdef VRDS16ILLEGAL
_os << "\\" << to_string(data[i]);
+#else
+ x16printf(buf, sizeof buf, data[i]);
+ _os << "\\" << buf;
+#endif
}
}
@@ -295,10 +347,21 @@ template<> inline void EncodingImplementation<VR::VRASCII>::Write(const double*
assert( data );
assert( length );
assert( _os );
+#ifdef VRDS16ILLEGAL
_os << to_string(data[0]);
+#else
+ char buf[16+1];
+ x16printf(buf, sizeof buf, data[0]);
+ _os << buf;
+#endif
for(unsigned long i=1; i<length; ++i) {
assert( _os );
+#ifdef VRDS16ILLEGAL
_os << "\\" << to_string(data[i]);
+#else
+ x16printf(buf, sizeof buf, data[i]);
+ _os << "\\" << buf;
+#endif
}
}
https://sourceforge.net/p/gdcm/gdcm/ci/79fd37a0c0e6d26d6a752dea063f21d2ee916e7b/
commit 79fd37a0c0e6d26d6a752dea063f21d2ee916e7b
Author: Mathieu Malaterre <mat...@gm...>
Date: Wed Oct 28 12:14:03 2015 +0100
Minimal support for MF Grascyale Byte/Word SC Image Storage
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx b/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
index c528ec2..863bc41 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmImageHelper.cxx
@@ -417,6 +417,8 @@ std::vector<double> ImageHelper::GetOriginValue(File const & f)
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
|| ms == MediaStorage::OphthalmicTomographyImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
const Tag t1(0x5200,0x9229);
@@ -535,6 +537,8 @@ std::vector<double> ImageHelper::GetDirectionCosinesValue(File const & f)
if( ms == MediaStorage::EnhancedCTImageStorage
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
const Tag t1(0x5200,0x9229);
@@ -794,42 +798,52 @@ std::vector<unsigned int> ImageHelper::GetDimensionsValue(const File& f)
return theReturn;
}
-void ImageHelper::SetDimensionsValue(File& f, const Image & img)
+void ImageHelper::SetDimensionsValue(File& f, const Pixmap & img)
{
const unsigned int *dims = img.GetDimensions();
MediaStorage ms;
ms.SetFromFile(f);
DataSet& ds = f.GetDataSet();
assert( MediaStorage::IsImage( ms ) );
-#if 0
- if( ms == MediaStorage::VLWholeSlideMicroscopyImageStorage )
- {
- Attribute<0x0048,0x0006> columns;
- columns.SetValue( dims[0] );
- ds.Replace( columns.GetAsDataElement() );
- Attribute<0x0048,0x0007> rows;
- rows.SetValue( dims[1] );
- ds.Replace( rows.GetAsDataElement() );
- if( dims[2] > 1 )
- {
- assert( 0 );
- }
- }
- else
-#endif
- {
+ {
Attribute<0x0028,0x0010> rows;
rows.SetValue( (uint16_t)dims[1] );
ds.Replace( rows.GetAsDataElement() );
Attribute<0x0028,0x0011> columns;
columns.SetValue( (uint16_t)dims[0] );
ds.Replace( columns.GetAsDataElement() );
- if( dims[2] > 1 )
+ Attribute<0x0028,0x0008> numframes = { 0 };
+ numframes.SetValue( dims[2] );
+ if( img.GetNumberOfDimensions() == 3 && dims[2] > 1 )
+ {
+ if( ms.MediaStorage::GetModalityDimension() > 2 )
+ ds.Replace( numframes.GetAsDataElement() );
+ else
+ {
+ gdcmErrorMacro( "MediaStorage does not allow 3rd dimension. But value is: " << dims[2] );
+ gdcmAssertAlwaysMacro( "Could not set third dimension" );
+ }
+ }
+ else // cleanup
+ ds.Remove( numframes.GetTag() );
+ }
+ // cleanup pass:
+ if( ms == MediaStorage::EnhancedCTImageStorage
+ || ms == MediaStorage::EnhancedMRImageStorage
+ || ms == MediaStorage::EnhancedPETImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
+ || ms == MediaStorage::SegmentationStorage )
+ {
+ const Tag tfgs(0x5200,0x9230);
+ if( ds.FindDataElement( tfgs ) )
{
- Attribute<0x0028,0x0008> numframes = { 0 };
- ds.Replace( numframes.GetAsDataElement() );
+ SmartPointer<SequenceOfItems> sqi = ds.GetDataElement( tfgs ).GetValueAsSQ();
+ assert( sqi );
+ sqi->SetNumberOfItems( dims[2] );
}
}
+
}
std::vector<double> ImageHelper::GetRescaleInterceptSlopeValue(File const & f)
@@ -1134,6 +1148,8 @@ std::vector<double> ImageHelper::GetSpacingValue(File const & f)
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
|| ms == MediaStorage::OphthalmicTomographyImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
// <entry group="5200" element="9230" vr="SQ" vm="1" name="Per-frame Functional Groups Sequence"/>
@@ -1400,6 +1416,8 @@ void ImageHelper::SetSpacingValue(DataSet & ds, const std::vector<double> & spac
if( ms == MediaStorage::EnhancedCTImageStorage
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
/*
@@ -1704,6 +1722,8 @@ void ImageHelper::SetOriginValue(DataSet & ds, const Image & image)
&& ms != MediaStorage::PETImageStorage
//&& ms != MediaStorage::ComputedRadiographyImageStorage
&& ms != MediaStorage::SegmentationStorage
+ && ms != MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ && ms != MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
&& ms != MediaStorage::EnhancedMRImageStorage
&& ms != MediaStorage::EnhancedPETImageStorage
&& ms != MediaStorage::EnhancedCTImageStorage )
@@ -1715,6 +1735,8 @@ void ImageHelper::SetOriginValue(DataSet & ds, const Image & image)
if( ms == MediaStorage::EnhancedCTImageStorage
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
/*
@@ -1783,6 +1805,8 @@ void ImageHelper::SetDirectionCosinesValue(DataSet & ds, const std::vector<doubl
&& ms != MediaStorage::RTDoseStorage
&& ms != MediaStorage::PETImageStorage
//&& ms != MediaStorage::ComputedRadiographyImageStorage
+ && ms != MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ && ms != MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
&& ms != MediaStorage::SegmentationStorage
&& ms != MediaStorage::EnhancedMRImageStorage
&& ms != MediaStorage::EnhancedPETImageStorage
@@ -1814,6 +1838,8 @@ void ImageHelper::SetDirectionCosinesValue(DataSet & ds, const std::vector<doubl
if( ms == MediaStorage::EnhancedCTImageStorage
|| ms == MediaStorage::EnhancedMRImageStorage
|| ms == MediaStorage::EnhancedPETImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleWordSecondaryCaptureImageStorage
+ || ms == MediaStorage::MultiframeGrayscaleByteSecondaryCaptureImageStorage
|| ms == MediaStorage::SegmentationStorage )
{
/*
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageHelper.h b/Source/MediaStorageAndFileFormat/gdcmImageHelper.h
index 9f7e745..fb5e4dc 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageHelper.h
+++ b/Source/MediaStorageAndFileFormat/gdcmImageHelper.h
@@ -29,6 +29,7 @@ class MediaStorage;
class DataSet;
class File;
class Image;
+class Pixmap;
class ByteValue;
/**
* \brief ImageHelper (internal class, not intended for user level)
@@ -70,7 +71,7 @@ public:
/// rows and columns of the image in pixels (as opposed to actual distances).
/// The output is {col , row}
static std::vector<unsigned int> GetDimensionsValue(const File& f);
- static void SetDimensionsValue(File& f, const Image & img);
+ static void SetDimensionsValue(File& f, const Pixmap & img);
/// This function returns pixel information about an image from its dataset
/// That includes samples per pixel and bit depth (in that order)
@@ -125,10 +126,10 @@ public:
//returns the configuration of colors in a plane, either RGB RGB RGB or RRR GGG BBB
static unsigned int GetPlanarConfigurationValue(const File& f);
- //returns the lookup table of an image file
+ /// returns the lookup table of an image file
static SmartPointer<LookupTable> GetLUT(File const& f);
- ///Moved from PixampReader to here. Generally used for photometric interpretation.
+ // Moved from PixampReader to here. Generally used for photometric interpretation.
static const ByteValue* GetPointerFromElement(Tag const &tag, File const& f);
/// Moved from MediaStorage here, since we need extra info stored in PixelFormat & PhotometricInterpretation
diff --git a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
index edab99d..78cca91 100644
--- a/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx
@@ -12,6 +12,7 @@
=========================================================================*/
#include "gdcmPixmapWriter.h"
+#include "gdcmImageHelper.h"
#include "gdcmTrace.h"
#include "gdcmDataSet.h"
#include "gdcmDataElement.h"
@@ -238,6 +239,7 @@ bool PixmapWriter::PrepareWrite()
const TransferSyntax &ts_orig = fmi_orig.GetDataSetTransferSyntax();
// col & rows:
+#if 0
Attribute<0x0028, 0x0011> columns;
columns.SetValue( (uint16_t)PixelData->GetDimension(0) );
ds.Replace( columns.GetAsDataElement() );
@@ -261,6 +263,9 @@ bool PixmapWriter::PrepareWrite()
assert( PixelData->GetDimension(2) == 1 );
ds.Remove( tnumberofframes );
}
+#else
+ ImageHelper::SetDimensionsValue(file, *PixelData);
+#endif
PixelFormat pf = PixelData->GetPixelFormat();
if ( !pf.IsValid() )
diff --git a/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx b/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx
index 2cbb9f2..d415339 100644
--- a/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmRescaler.cxx
@@ -391,7 +391,7 @@ bool Rescaler::Rescale(char *out, const char *in, size_t n)
return true;
}
-PixelFormat ComputeInverseBestFitFromMinMax(/*const PixelFormat &pf,*/ double intercept, double slope, double _min, double _max)
+static PixelFormat ComputeInverseBestFitFromMinMax(/*const PixelFormat &pf,*/ double intercept, double slope, double _min, double _max)
{
PixelFormat st = PixelFormat::UNKNOWN;
//assert( slope == (int)slope && intercept == (int)intercept);
@@ -428,7 +428,7 @@ PixelFormat ComputeInverseBestFitFromMinMax(/*const PixelFormat &pf,*/ double in
}
else
{
- assert(0);
+ gdcmAssertAlwaysMacro(0);
}
int64_t max2 = max; // make a copy
while (max2 >>= 1) ++log2max;
@@ -454,7 +454,7 @@ PixelFormat ComputeInverseBestFitFromMinMax(/*const PixelFormat &pf,*/ double in
}
else
{
- assert(0);
+ gdcmAssertAlwaysMacro(0);
}
assert( min < 0 );
#if 0
https://sourceforge.net/p/gdcm/gdcm/ci/d7d7e3b807f86beab35c7eedebd33379b0e799d6/
commit d7d7e3b807f86beab35c7eedebd33379b0e799d6
Author: Mathieu Malaterre <mat...@gm...>
Date: Wed Oct 28 12:13:31 2015 +0100
Remove a simple warning
diff --git a/Applications/Cxx/gdcmtar.cxx b/Applications/Cxx/gdcmtar.cxx
index 7687625..5ee1774 100644
--- a/Applications/Cxx/gdcmtar.cxx
+++ b/Applications/Cxx/gdcmtar.cxx
@@ -131,6 +131,7 @@ class frame_diff /* */
public:
bool operator<(const frame_diff &rhs) const
{
+ (void)rhs;
return true;
}
};
-----------------------------------------------------------------------
Summary of changes:
Applications/Cxx/gdcmtar.cxx | 1 +
.../gdcmElement.h | 63 ++++++++++++++++++
.../MediaStorageAndFileFormat/gdcmImageHelper.cxx | 68 ++++++++++++++------
Source/MediaStorageAndFileFormat/gdcmImageHelper.h | 7 +-
.../MediaStorageAndFileFormat/gdcmPixmapWriter.cxx | 5 ++
Source/MediaStorageAndFileFormat/gdcmRescaler.cxx | 6 +-
6 files changed, 123 insertions(+), 27 deletions(-)
hooks/post-receive
--
Grassroots DICOM
|