Skip to content
forked from sprinfall/dcm

A lightweight C++ DICOM library.

License

Notifications You must be signed in to change notification settings

feliwir/dcmlite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dcmcore

A lightweight C++ DICOM library for reading and writing DICOM files.

Usage

Read Full Data Set

dcmcore::DataSet data_set;
dcmcore::FullReadHandler read_handler(&data_set);
dcmcore::DicomReader reader(&read_handler);
reader.ReadFile("path/to/some/dcm");

With the data set, you can get tags.

Read string:

std::string transfer_syntax_uid;
if (data_set.GetString(dcmcore::Tag(0x0002, 0x0010), &transfer_syntax_uid)) {
  std::cout << "Transfer Syntax UID: " << transfer_syntax_uid << std::endl;
}

std::string patient_name;
if (data_set.GetString(dcmcore::Tag(0x0010, 0x0010), &patient_name)) {
  std::cout << "Patient Name: " << patient_name << std::endl;
}

Read integer:

std::uint16_t samples_per_pixel;
if (data_set.GetUint16(dcmcore::Tag(0x0028, 0x0002), &samples_per_pixel)) {
  std::cout << "Samples Per Pixel: " << samples_per_pixel << std::endl;
}

Read Specific Tags

Much less memory allocation thus much faster.

dcmcore::DataSet data_set;
dcmcore::TagsReadHandler read_handler(&data_set);

// Add tags to read.
read_handler.AddTag(dcmcore::Tag(0x0002, 0x0010)).
    AddTag(dcmcore::Tag(0x0010, 0x0010)).
    AddTag(dcmcore::Tag(0x0028, 0x0002));

dcmcore::DicomReader reader(&read_handler);
reader.ReadFile("path/to/some/dcm")

// Get value from data set.
// ...

Write

Write a data set to a file:

  dcmcore::BinaryFile file;
  if (!file.Open("output.dcm", dcmcore::BinaryFile::Mode::WRITE)) {
    std::cerr << "Failed to open output file.\n";
    return;
  }

  dcmcore::WriteVisitor visitor(&file);
  data_set.Accept(visitor);

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.9%
  • Other 1.1%