Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2006/05/02 13:11:57 $
- Version: $Revision: 1.103 $
+ Date: $Date: 2006/07/04 07:58:51 $
+ Version: $Revision: 1.106 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param lgth new value length
* @param group Group number of the Entry
* @param elem Element number of the Entry
+ * @param vr Value Represenation of the DataElement to be inserted
* \return pointer to the modified/created DataEntry (NULL when creation
* failed).
*/
return GetRaw();
}
-#ifndef GDCM_LEGACY_REMOVE
+//#ifndef GDCM_LEGACY_REMOVE
/*
* \brief Useless function, since PixelReadConverter forces us
* copy the Pixels anyway.
* @return On success, the number of bytes actually copied. Zero on
* failure e.g. MaxSize is lower than necessary.
*/
+ /*
size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize)
{
if ( ! GetRaw() )
PixelReadConverter->GetRawSize() );
return PixelReadConverter->GetRawSize();
}
-#endif
+*/
+//#endif
/**
* \brief Points the internal pointer to the callers inData
}
break;
- SetWriteFileTypeToExplicitVR(); // to see JPRx
+ SetWriteFileTypeToExplicitVR(); // to see JPRx
break;
case ACR:
case ACR_LIBIDO:
vr = "OW";
if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files
vr = "OB";
+ // For non RAW data. Mainly JPEG
+ if( WriteType == JPEG )
+ {
+ vr = "OW";
+ }
DataEntry *pixel =
CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
// Replace deprecated 0028 0012 US Planes
// by new 0028 0008 IS Number of Frames
+
+ ///\todo : find if there is a rule!
DataEntry *e_0028_0012 = FileInternal->GetDataEntry(0x0028, 0x0012);
if ( e_0028_0012 )
{
// we write it only when we are *sure* the image comes from
// an imager (see also 0008,0x0064)
CheckMandatoryEntry(0x0018,0x1164,pixelSpacing,"DS");
+
+
+
+/*
+///Exact meaning of RETired fields
+
+// See page 73 of ACR-NEMA_300-1988.pdf !
+
+// 0020,0020 : Patient Orientation :
+Patient direction of the first row and
+column of the images. The first entry id the direction of the raws, given by the
+direction of the last pixel in the first row from the first pixel in tha row.
+the second entry is the direction of the columns, given by the direction of the
+last pixel in the first column from the first pixel in that column.
+L : Left, F : Feet, A : Anterior, P : Posterior.
+Up to 3 letters can be used in combination to indicate oblique planes.
+
+//0020,0030 Image Position (RET)
+x,y,z coordinates im mm of the first pixel in the image
+
+// 0020,0035 Image Orientation (RET)
+Direction cosines of the R axis of the image system with respect to the
+equipment coordinate axes x,y,z, followed by direction cosines of the C axis of
+the image system with respect to the same axes
+
+//0020,0050 Location
+An image location reference, standard for the modality (such as CT bed
+position), used to indicate position. Calculation of position for other purposes
+is only from (0020,0030) and (0020,0035)
+*/
+
+/*
+// if imagePositionPatient not found, default it with imagePositionRet, if any
+// if imageOrientationPatient not found, default it with imageOrientationRet, if any
+
+ std::string imagePositionRet = FileInternal->GetEntryString(0x0020,0x0030);
+ std::string imageOrientationRet = FileInternal->GetEntryString(0x0020,0x0035);
+ std::string imagePositionPatient = FileInternal->GetEntryString(0x0020,0x0032);
+ std::string imageOrientationPatient = FileInternal->GetEntryString(0x0020,0x0037);
+ if( imagePositionPatient == GDCM_UNFOUND && imageOrientationPatient == GDCM_UNFOUND
+ && imagePositionRet != GDCM_UNFOUND && imageOrientationRet != GDCM_UNFOUND)
+ {
+ CopyMandatoryEntry(0x0020, 0x0032,imagePositionRet,"DS");
+ Archive->Push(0x0020,0x0030);
+ CopyMandatoryEntry(0x0020, 0x0037,imageOrientationRet,"DS");
+ Archive->Push(0x0020,0x0035);
+ }
+*/
+
// Samples Per Pixel (type 1) : default to grayscale
CheckMandatoryEntry(0x0028,0x0002,"1","US");
//-----------------------------------------------------------------------------
} // end namespace gdcm
+
+
+/* Probabely something to be added to use Rescale Slope/Intercept
+Have a look ,at ITK code !
+
+// Internal function to rescale pixel according to Rescale Slope/Intercept
+template<class TBuffer, class TSource>
+void RescaleFunction(TBuffer* buffer, TSource *source,
+ double slope, double intercept, size_t size)
+{
+ size /= sizeof(TSource);
+
+ if (slope != 1.0 && intercept != 0.0)
+ {
+ // Duff's device. Instead of this code:
+ //
+ // for(unsigned int i=0; i<size; i++)
+ // {
+ // buffer[i] = (TBuffer)(source[i]*slope + intercept);
+ // }
+ //
+ // use Duff's device which exploits "fall through"
+ register size_t n = (size + 7) / 8;
+ switch ( size % 8)
+ {
+ case 0: do { *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 7: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 6: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 5: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 4: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 3: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 2: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ case 1: *buffer++ = (TBuffer)((*source++)*slope + intercept);
+ } while (--n > 0);
+ }
+ }
+ else if (slope == 1.0 && intercept != 0.0)
+ {
+ // Duff's device. Instead of this code:
+ //
+ // for(unsigned int i=0; i<size; i++)
+ // {
+ // buffer[i] = (TBuffer)(source[i] + intercept);
+ // }
+ //
+ // use Duff's device which exploits "fall through"
+ register size_t n = (size + 7) / 8;
+ switch ( size % 8)
+ {
+ case 0: do { *buffer++ = (TBuffer)(*source++ + intercept);
+ case 7: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 6: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 5: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 4: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 3: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 2: *buffer++ = (TBuffer)(*source++ + intercept);
+ case 1: *buffer++ = (TBuffer)(*source++ + intercept);
+ } while (--n > 0);
+ }
+ }
+ else if (slope != 1.0 && intercept == 0.0)
+ {
+ // Duff's device. Instead of this code:
+ //
+ // for(unsigned int i=0; i<size; i++)
+ // {
+ // buffer[i] = (TBuffer)(source[i]*slope);
+ // }
+ //
+ // use Duff's device which exploits "fall through"
+ register size_t n = (size + 7) / 8;
+ switch ( size % 8)
+ {
+ case 0: do { *buffer++ = (TBuffer)((*source++)*slope);
+ case 7: *buffer++ = (TBuffer)((*source++)*slope);
+ case 6: *buffer++ = (TBuffer)((*source++)*slope);
+ case 5: *buffer++ = (TBuffer)((*source++)*slope);
+ case 4: *buffer++ = (TBuffer)((*source++)*slope);
+ case 3: *buffer++ = (TBuffer)((*source++)*slope);
+ case 2: *buffer++ = (TBuffer)((*source++)*slope);
+ case 1: *buffer++ = (TBuffer)((*source++)*slope);
+ } while (--n > 0);
+ }
+ }
+ else
+ {
+ // Duff's device. Instead of this code:
+ //
+ // for(unsigned int i=0; i<size; i++)
+ // {
+ // buffer[i] = (TBuffer)(source[i]);
+ // }
+ //
+ // use Duff's device which exploits "fall through"
+ register size_t n = (size + 7) / 8;
+ switch ( size % 8)
+ {
+ case 0: do { *buffer++ = (TBuffer)(*source++);
+ case 7: *buffer++ = (TBuffer)(*source++);
+ case 6: *buffer++ = (TBuffer)(*source++);
+ case 5: *buffer++ = (TBuffer)(*source++);
+ case 4: *buffer++ = (TBuffer)(*source++);
+ case 3: *buffer++ = (TBuffer)(*source++);
+ case 2: *buffer++ = (TBuffer)(*source++);
+ case 1: *buffer++ = (TBuffer)(*source++);
+ } while (--n > 0);
+ }
+ }
+
+
+}
+
+
+template<class TSource>
+void RescaleFunction(ImageIOBase::IOComponentType bufferType,
+ void* buffer, TSource *source,
+ double slope, double intercept, size_t size)
+{
+ switch (bufferType)
+ {
+ case ImageIOBase::UCHAR:
+ RescaleFunction( (unsigned char *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::CHAR:
+ RescaleFunction( (char *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::USHORT:
+ RescaleFunction( (unsigned short *)buffer, source, slope, intercept,size);
+ break;
+ case ImageIOBase::SHORT:
+ RescaleFunction( (short *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::UINT:
+ RescaleFunction( (unsigned int *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::INT:
+ RescaleFunction( (int *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::FLOAT:
+ RescaleFunction( (float *)buffer, source, slope, intercept, size);
+ break;
+ case ImageIOBase::DOUBLE:
+ RescaleFunction( (double *)buffer, source, slope, intercept, size);
+ break;
+ default:
+ ::itk::OStringStream message;
+ message << "itk::ERROR: GDCMImageIO: Unknown component type : " << bufferType;
+ ::itk::ExceptionObject e(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION);
+ throw e;
+ }
+}
+*/