GDCM 3.0.24
TemplateEmptyImage.cxx
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "gdcmTag.h"
#include "gdcmTrace.h"
#include "gdcmWriter.h"
#include "gdcmTagKeywords.h"
int main(int argc, char *argv[])
{
if( argc < 2 ) return 1;
const char * filename = argv[1];
irr.SetFileName( filename );
const bool b3 = irr.ReadInformation();
std::cout << b3 << std::endl;
gdcm::Image & img = irr.GetImage();
std::cout << img << std::endl;
// const gdcm::Region & r = irr.GetRegion();
// std::cout << r << std::endl;
gdcm::File & file = w.GetFile();
gdcm::DataSet & ds = file.GetDataSet();
namespace kwd = gdcm::Keywords;
kwd::FrameOfReferenceUID frameref;
frameref.SetValue( uid.Generate() );
// ContentDate
char date[22];
const size_t datelen = 8;
(void)res;
kwd::ContentDate contentdate;
// Do not copy the whole cstring:
contentdate.SetValue( gdcm::DAComp( date, datelen ) );
ds.Insert( contentdate.GetAsDataElement() );
// ContentTime
const size_t timelen = 6 + 1 + 6; // time + milliseconds
kwd::ContentTime contenttime;
// Do not copy the whole cstring:
contenttime.SetValue( gdcm::TMComp(date+datelen, timelen) );
ds.Insert( contenttime.GetAsDataElement() );
std::cout << ms0 << std::endl;
kwd::SeriesNumber seriesnumber = { 1 };
kwd::InstanceNumber instancenum = { 1 };
kwd::StudyID studyid = { "St1" };
kwd::PatientID patientid = { "P1" };
kwd::SOPClassUID sopclassuid;
kwd::PositionReferenceIndicator pri;
//kwd::Laterality lat;
//kwd::BodyPartExamined bodypartex = { "HEAD" };
kwd::BodyPartExamined bodypartex = { "ANKLE" };
kwd::PatientOrientation pator;
kwd::BurnedInAnnotation bia = { "NO" };
kwd::ConversionType convtype = { "SYN" };
kwd::PresentationLUTShape plutshape = { "IDENTITY" }; // MONOCHROME2
// gdcm will pick the Word in case Byte class is not compatible:
sopclassuid.SetValue( ms.GetString() );
ds.Insert( instancenum.GetAsDataElement() );
ds.Insert( sopclassuid.GetAsDataElement() );
ds.Insert( seriesnumber.GetAsDataElement() );
ds.Insert( patientid.GetAsDataElement() );
ds.Insert( studyid.GetAsDataElement() );
ds.Insert( frameref.GetAsDataElement() );
ds.Insert( pri.GetAsDataElement() );
//ds.Insert( lat.GetAsDataElement() );
ds.Insert( bodypartex.GetAsDataElement() );
ds.Insert( pator.GetAsDataElement() );
ds.Insert( bia.GetAsDataElement() );
ds.Insert( convtype.GetAsDataElement() );
ds.Insert( plutshape.GetAsDataElement() );
// gdcm::MediaStorage ms1 = w.ComputeTargetMediaStorage();
// std::cout << ms1 << std::endl;
std::cout << ds << std::endl;
pf.SetPixelRepresentation(0); // always overwrite
img.SetSlope(1);
img.SetIntercept(0);
w.SetImage( img );
w.SetFileName( "TemplateImage.dcm" );
if( !w.Write() )
{
return 1;
}
return 0;
}
const PixelFormat & GetPixelFormat() const
Get/Set PixelFormat.
Definition gdcmBitmap.h:107
Class to represent a Data Set (which contains Data Elements)
Definition gdcmDataSet.h:56
void Insert(const DataElement &de)
Definition gdcmDataSet.h:128
a DICOM File
Definition gdcmFile.h:34
const DataSet & GetDataSet() const
Get Data Set.
Definition gdcmFile.h:57
const Image & GetImage() const
Return the read image.
ImageRegionReader.
Definition gdcmImageRegionReader.h:35
ImageWriter.
Definition gdcmImageWriter.h:33
MediaStorage ComputeTargetMediaStorage()
bool Write() override
Write.
Image.
Definition gdcmImage.h:47
void SetSlope(double slope)
slope
Definition gdcmImage.h:92
void SetIntercept(double intercept)
intercept
Definition gdcmImage.h:88
MediaStorage.
Definition gdcmMediaStorage.h:44
@ MultiframeGrayscaleByteSecondaryCaptureImageStorage
Definition gdcmMediaStorage.h:67
const char * GetString() const
Return the Media String of the object.
PixelFormat.
Definition gdcmPixelFormat.h:46
void SetPixelRepresentation(unsigned short pr)
Definition gdcmPixelFormat.h:177
virtual void SetImage(Pixmap const &img)
void SetFileName(const char *filename_native)
String.
Definition gdcmString.h:32
static bool GetCurrentDateTime(char date[22])
Class for generating unique UID.
Definition gdcmUIDGenerator.h:28
const char * Generate()
File & GetFile()
Definition gdcmWriter.h:67
void SetFileName(const char *filename_native)
Set the filename of DICOM file to write: