- * \ingroup gdcmHeader
- * \brief
- * @return Lookup Table RGB
- * \ when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
- * \ and (0028,1201),(0028,1202),(0028,1202) are found
- * \warning : hazardous ! Use better GetPubElValVoidAreaByNumber
- */
-void * gdcmHeader::GetLUTRGB(void) {
-// Not so easy : see
-// http://www.barre.nom.fr/medical/dicom2/limitations.html#Color%20Lookup%20Tables
-// and OT-PAL-8-face.dcm
-
- if (GetPubElValByNumber(0x0028,0x0004) == "gdcm::Unfound") {
- dbg.Verbose(0, "gdcmHeader::GetLUTRGB: unfound Photometric Interpretation");
- return NULL;
- }
- void * LutR,*LutG,*LutB;
- int l;
-
- // Maybe, some day we get an image
- // that respects the definition ...
- // Let's consider no ones does.
-
- l= GetLUTLength();
- if(l==0)
- return (NULL);
- int nBits=GetLUTNbits();
- // a virer quand on aura trouve UNE image
- // qui correspond VRAIMENT à la definition !
- cout << "l " << l << " nBits " << nBits;
-
- l= l/(nBits/8);
-
- LutR =GetPubElValVoidAreaByNumber(0x0028,0x1201);
- LutG =GetPubElValVoidAreaByNumber(0x0028,0x1202);
- LutB =GetPubElValVoidAreaByNumber(0x0028,0x1203);
-
- // Warning : Any value for nBits as to be considered as 8
- // Any value for Length as to be considered as 256
- // That's DICOM ...
-
- // Just wait before removing the following code
- /*
- if (nBits == 16) {
- guint16 * LUTRGB, *rgb;
- LUTRGB = rgb = (guint16 *) malloc(3*l*sizeof( guint16));
- guint16 * r = (guint16 *)LutR;
- guint16 * g = (guint16 *)LutG;
- guint16 * b = (guint16 *)LutB;
- for(int i=0;i<l;i++) {
- *rgb++ = *r++;
- *rgb++ = *g++;
- *rgb++ = *b++;
- }
- return(LUTRGB);
- } else
-
- */ { // we assume it's always 8 Bits
- l=256; // we assume ...
- unsigned char * LUTRGB, *rgb;
- LUTRGB = rgb = (unsigned char *) malloc(3*l*sizeof( char));
- unsigned char * r = (unsigned char *)LutR;
- unsigned char * g = (unsigned char *)LutG;
- unsigned char * b = (unsigned char *)LutB;
- for(int i=0;i<l;i++) {
- //cout << "lut16 " << i << " : " << *r << " " << *g << " " << *b << "\n";
- printf("lut 8 %d : %d %d %d \n",i,*r,*g,*b);
- *rgb++ = *r++;
- *rgb++ = *g++;
- *rgb++ = *b++;
- }
- free(LutR); free(LutB); free(LutG);
- return(LUTRGB);
- }
+ * \brief Initialize a default DICOM header that should contain all the
+ * field require by other reader. DICOM standard does not
+ * explicitely defines those fields, heuristic has been choosen.
+ * This is not perfect as we are writting a CT image...
+ */
+void Header::InitializeDefaultHeader()
+{
+ typedef struct
+ {
+ const char *value;
+ uint16_t group;
+ uint16_t elem;
+ } DICOM_DEFAULT_VALUE;
+
+ std::string date = Util::GetCurrentDate();
+ std::string time = Util::GetCurrentTime();
+ std::string uid = Util::CreateUniqueUID();
+ std::string uidMedia = uid;
+ std::string uidClass = uid + ".1";
+ std::string uidInst = uid + ".10";
+ std::string uidStudy = uid + ".100";
+ std::string uidSerie = uid + ".1000";
+
+ static DICOM_DEFAULT_VALUE defaultvalue[] = {
+ { "146 ", 0x0002, 0x0000}, // Meta Element Group Length // FIXME: how to recompute ?
+ { "1.2.840.10008.5.1.4.1.1.2", 0x0002, 0x0002}, // Media Storage SOP Class UID (CT Image Storage)
+ { uidClass.c_str(), 0x0002, 0x0003}, // Media Storage SOP Instance UID
+ { uidClass.c_str(), 0x0002, 0x0012}, // META Implementation Class UID
+ { "GDCM", 0x0002, 0x0016}, // Source Application Entity Title
+
+ { date.c_str(), 0x0008, 0x0012}, // Instance Creation Date
+ { time.c_str(), 0x0008, 0x0013}, // Instance Creation Time
+ { "1.2.840.10008.5.1.4.1.1.2", 0x0008, 0x0016}, // SOP Class UID
+ { uidInst.c_str(), 0x0008, 0x0018}, // SOP Instance UID
+ { "CT", 0x0008, 0x0060}, // Modality
+ { "GDCM", 0x0008, 0x0070}, // Manufacturer
+ { "GDCM", 0x0008, 0x0080}, // Institution Name
+ { "http://www-creatis.insa-lyon.fr/Public/Gdcm", 0x0008, 0x0081}, // Institution Address
+
+ { "GDCM", 0x0010, 0x0010}, // Patient's Name
+ { "GDCMID", 0x0010, 0x0020}, // Patient ID
+
+ { uidStudy.c_str(), 0x0020, 0x000d}, // Study Instance UID
+ { uidSerie.c_str(), 0x0020, 0x000e}, // Series Instance UID
+ { "1", 0x0020, 0x0010}, // StudyID
+ { "1", 0x0020, 0x0011}, // SeriesNumber
+
+ { "1", 0x0028, 0x0002}, // Samples per pixel 1 or 3
+ { "MONOCHROME1", 0x0028, 0x0004}, // photochromatic interpretation
+ { "0", 0x0028, 0x0010}, // nbRows
+ { "0", 0x0028, 0x0011}, // nbCols
+ { "8", 0x0028, 0x0100}, // BitsAllocated 8 or 12 or 16
+ { "8", 0x0028, 0x0101}, // BitsStored <= BitsAllocated
+ { "7", 0x0028, 0x0102}, // HighBit <= BitsAllocated - 1
+ { "0", 0x0028, 0x0103}, // Pixel Representation 0(unsigned) or 1(signed)
+ { 0, 0, 0 }
+ };
+
+ // default value
+ // Special case this is the image (not a string)
+ GrPixel = 0x7fe0;
+ NumPixel = 0x0010;
+ ReplaceOrCreate(0, 0, GrPixel, NumPixel);
+
+ // All remaining strings:
+ unsigned int i = 0;
+ DICOM_DEFAULT_VALUE current = defaultvalue[i];
+ while( current.value )
+ {
+ ReplaceOrCreate(current.value, current.group, current.elem);
+ current = defaultvalue[++i];
+ }