https://github.com/sprinfall/dcm
A lightweight C++ DICOM library (for study purpose only!)
https://github.com/sprinfall/dcm
cpp cpp11 dicom
Last synced: 4 months ago
JSON representation
A lightweight C++ DICOM library (for study purpose only!)
- Host: GitHub
- URL: https://github.com/sprinfall/dcm
- Owner: sprinfall
- Created: 2016-10-31T00:57:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-04T01:54:32.000Z (about 3 years ago)
- Last Synced: 2024-03-21T02:31:21.660Z (almost 2 years ago)
- Topics: cpp, cpp11, dicom
- Language: C++
- Homepage:
- Size: 12.2 MB
- Stars: 30
- Watchers: 4
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dcm
NOTE: This project is only for study purpose. Please consider to use DCMTK in your project.
A lightweight C++ DICOM library for reading and writing DICOM files.
## Usage
### Read DICOM File
```cpp
dcm::DicomFile dicom_file("path/to/some/dcm");
if (!dicom_file.Load()) {
std::cerr << "Failed to load the file." << std::endl;
return;
}
```
Read string:
```cpp
std::string transfer_syntax_uid;
if (dicom_file.GetString(dcm::tags::kTransferSyntaxUID, &transfer_syntax_uid)) {
// ...
}
std::string patient_name;
if (dicom_file.GetString(dcm::tags::kPatientName, &patient_name)) {
// ...
}
```
Or:
```cpp
auto transfer_syntax_uid = dicom_file.GetString(dcm::tags::kTransferSyntaxUID);
auto patient_name = dicom_file.GetString(dcm::tags::kPatientName);
```
Read integer:
```cpp
std::uint16_t samples_per_pixel;
if (dicom_file.GetUint16(dcm::tags::kSamplesPerPixel, &samples_per_pixel)) {
// ...
}
```
Or:
```cpp
auto samples_per_pixel = dicom_file.GetUint16(dcm::tags::kSamplesPerPixel, 0);
```