Example #1
0
    // Create a 256 x 256 Secondary Capture Image Storage
    static private void CreateSmallDICOM(string fileName)
    {
        using (var writer = new gdcm.PixmapWriter())
        {
            gdcm.Pixmap img = writer.GetImage();
            img.SetNumberOfDimensions(3);
            img.SetDimension(0, 512);
            img.SetDimension(1, 512);
            img.SetDimension(2, 2); // fake a 3d volume
            PhotometricInterpretation pi = new PhotometricInterpretation(PhotometricInterpretation.PIType.MONOCHROME2);
            img.SetPhotometricInterpretation(pi);
            gdcm.DataElement pixeldata = new gdcm.DataElement(new gdcm.Tag(0x7fe0, 0x0010));
            byte[]           buffer    = new byte[512 * 512 * 2];
            pixeldata.SetByteValue(buffer, new gdcm.VL((uint)buffer.Length));
            img.SetDataElement(pixeldata);

            gdcm.File        file         = writer.GetFile();
            gdcm.DataSet     ds           = file.GetDataSet();
            gdcm.DataElement ms           = new gdcm.DataElement(new gdcm.Tag(0x0008, 0x0016));
            string           mediastorage = "1.2.840.10008.5.1.4.1.1.7.2"; // Multi-frame Grayscale Byte Secondary Capture Image Storage
            byte[]           val          = StrToByteArray(mediastorage);
            ms.SetByteValue(val, new gdcm.VL((uint)val.Length));
            ds.Insert(ms);

            writer.SetFileName(fileName);
            writer.Write();
        }
    }
  // Create a 256 x 256 Secondary Capture Image Storage
  static private void CreateSmallDICOM(string fileName)
    {
    using( var writer = new gdcm.PixmapWriter() )
      {
      gdcm.Pixmap img = writer.GetImage();
      img.SetNumberOfDimensions( 3 );
      img.SetDimension(0, 512 );
      img.SetDimension(1, 512 );
      img.SetDimension(2, 2 ); // fake a 3d volume
      PhotometricInterpretation pi = new PhotometricInterpretation( PhotometricInterpretation.PIType.MONOCHROME2 );
      img.SetPhotometricInterpretation( pi );
      gdcm.DataElement pixeldata = new gdcm.DataElement( new gdcm.Tag(0x7fe0,0x0010) );
      byte[] buffer = new byte[ 512 * 512 * 2 ];
      pixeldata.SetByteValue( buffer, new gdcm.VL((uint)buffer.Length) );
      img.SetDataElement( pixeldata );

      gdcm.File file = writer.GetFile();
      gdcm.DataSet ds = file.GetDataSet();
      gdcm.DataElement ms = new gdcm.DataElement(new gdcm.Tag(0x0008,0x0016));
      string mediastorage = "1.2.840.10008.5.1.4.1.1.7.2"; // Multi-frame Grayscale Byte Secondary Capture Image Storage
      byte[] val = StrToByteArray(mediastorage);
      ms.SetByteValue( val, new gdcm.VL( (uint)val.Length) );
      ds.Insert( ms );

      writer.SetFileName( fileName );
      writer.Write();
      }
    }
Example #3
0
    float[] GetImagePosition(gdcm.DataSet dataset)
    {
        gdcm.DataElement element       = dataset.GetDataElement(Tags.ImagePosition);
        string           valueAsString = element.GetByteValue().toString();
        var partsAsString = valueAsString.Split('\\');
        var partsAsFloat  = partsAsString.Select(part => float.Parse(part,
                                                                     System.Globalization.CultureInfo.InvariantCulture)).ToArray();

        return(partsAsFloat);
    }
Example #4
0
 string GetSeriesUid(gdcm.DataSet dataset)
 {
     gdcm.DataElement element = dataset.GetDataElement(Tags.SeriesInstanceUID);
     return(element.GetValue().toString());
 }
Example #5
0
 string GetPatientName(gdcm.DataSet dataset)
 {
     //Os mecanismos de gdcm::Attribute tb estão quebrados.
     gdcm.DataElement element = dataset.GetDataElement(Tags.PatientName);
     return(element.GetValue().toString());
 }