1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/*=========================================================================
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.
=========================================================================*/
/*
* This example was created during the GSOC 2011 project for
* JPIP
*/
#include "gdcmAnonymizer.h"
#include "gdcmWriter.h"
#include "gdcmUIDGenerator.h"
#include "gdcmFile.h"
#include "gdcmTag.h"
#include "gdcmSystem.h"
#include "gdcmAttribute.h"
int main(int argc, char *argv[])
{
if( argc < 2 )
{
std::cerr << argv[0] << " output.dcm" << std::endl;
return 1;
}
const char *outfilename = argv[1];
gdcm::Writer w;
gdcm::File &file = w.GetFile();
gdcm::DataSet &ds = file.GetDataSet();
//w.SetCheckFileMetaInformation( true );
w.SetFileName( outfilename );
file.GetHeader().SetDataSetTransferSyntax( gdcm::TransferSyntax::JPIPReferenced );
gdcm::Anonymizer anon;
anon.SetFile( file );
gdcm::MediaStorage ms = gdcm::MediaStorage::SecondaryCaptureImageStorage;
gdcm::UIDGenerator gen;
anon.Replace( gdcm::Tag(0x0008,0x16), ms.GetString() );
std::cout << ms.GetString() << std::endl;
anon.Replace( gdcm::Tag(0x0008,0x18), gen.Generate() );
//
anon.Replace( gdcm::Tag(0x0010,0x10), "JPIP^EXAMPLE" );
anon.Replace( gdcm::Tag(0x0010,0x20), "012345" );
anon.Empty( gdcm::Tag(0x0010,0x30) );
anon.Empty( gdcm::Tag(0x0010,0x40) );
anon.Empty( gdcm::Tag(0x0008,0x20) );
anon.Empty( gdcm::Tag(0x0008,0x30) );
anon.Empty( gdcm::Tag(0x0008,0x90) );
anon.Empty( gdcm::Tag(0x0020,0x10) );
anon.Empty( gdcm::Tag(0x0020,0x11) );
anon.Empty( gdcm::Tag(0x0008,0x50) );
anon.Empty( gdcm::Tag(0x0020,0x0013) );
anon.Replace( gdcm::Tag(0x0020,0xd), gen.Generate() );
anon.Replace( gdcm::Tag(0x0020,0xe), gen.Generate() );
anon.Replace( gdcm::Tag(0x0008,0x64), "WSD " );
anon.Replace( gdcm::Tag(0x0008,0x60), "OT" );
gdcm::Attribute<0x0028,0x7FE0> at;
at.SetValue( "http://dicom.example.com/jpipserver.cgi?target=img.jp2" );
ds.Insert( at.GetAsDataElement() );
// Need to retrieve the PixelFormat information from the given file
if (!w.Write() )
{
std::cerr << "Could not write: " << outfilename << std::endl;
return 1;
}
return 0;
}
|