Nifti and Dicom support example.
#include <iostream>
using namespace std;
int main()
{
cout << "Reading a nifti Image" << endl;
if (!
NiftiRead(
"../examples/data/nifti/LR_nifti.nii", nifti_image)) {
return EXIT_FAILURE;
}
ResizeDim(nifti_image, nifti_image, { 256, 256, 256 });
int gamma = 3;
cout << "Executing GammaContrast" << endl;
cout << "Save a nifti Image" << endl;
cout << "Reading a dicom Image" << endl;
if (!
DicomRead(
"../examples/data/dicom/ISIC_0000008.dcm", dicom_image)) {
return EXIT_FAILURE;
}
string key = "fake_meta";
int value = 8;
if (dicom_image.
SetMeta(key, value)) {
cout << "[" << key << "]" << " = " << value << " inserted" << endl;
}
else {
cout << "[" << key << "]" << " = " << value << " updated" << endl;
}
auto rows = dicom_image.
GetMeta(
"Rows");
unsigned short r = any_cast<unsigned short>(rows.Get());
cout << "Rows: " << r << endl;
cout << "Rows: " << r_str << endl;
for (
auto& p : dicom_image.
meta_) {
cout << p.first << " - " << p.second.GetStr() << endl;
}
cout << "Executing ChangeColorSpace" << endl;
cout << "Executing OtsuThreshold" << endl;
double maxval = 255;
cout << "Executing Threshold" << endl;
Threshold(dicom_image, dicom_image, thresh, maxval);
cout << "Save a dicom Image" << endl;
if (!
ImRead(
"../examples/data/test.jpg", img)) {
return EXIT_FAILURE;
}
cout << "Save a nifti from .jpg Image" << endl;
cout << "Save a dicom from .jpg Image" << endl;
return EXIT_SUCCESS;
}