-
Notifications
You must be signed in to change notification settings - Fork 0
/
mammography.cpp
83 lines (81 loc) · 4.1 KB
/
mammography.cpp
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
83
#include "mammography.h"
void mammography::loadHeaderData(const std::string fileName){
DcmFileFormat fileformat;
const char* fName = fileName.c_str();
OFCondition status = fileformat.loadFile(fName);
if(status.good()){
if (fileformat.getDataset()->findAndGetLongInt(DCM_XRayTubeCurrent, XRayTubeCurrent).good()){
}else
std::cerr << "Error: cannot access XRayTubeCurrent!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_KVP, KVP).good()){
}else
std::cerr << "Error: cannot access KVP!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_Exposure, Exposure).good()){
}else
std::cerr << "Error: cannot access Exposure!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_BodyPartThickness, BodyPartThickness).good()){
}else
std::cerr << "Error: cannot access BodyPartThickness!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_CompressionForce, CompressionForce).good()){
}else
std::cerr << "Error: cannot access CompressionForce!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_Rows, Rows).good()){
}else
std::cerr << "Error: cannot access Rows!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_Columns, Columns).good()){
}else
std::cerr << "Error: cannot access Columns!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_BitsAllocated, BitsAllocated).good()){
}else
std::cerr << "Error: cannot access BitsAllocated!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_PixelRepresentation, PixelRepresentation).good()){
}else
std::cerr << "Error: cannot access PixelRepresentation!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_SmallestImagePixelValue, SmallestImagePixelValue).good()){
}else
std::cerr << "Error: cannot access SmallestImagePixelValue!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_LargestImagePixelValue, LargestImagePixelValue).good()){
}else
std::cerr << "Error: cannot access LargestImagePixelValue!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_FilterMaterial, Filter).good()){
}else
std::cerr << "Error: cannot access FilterMaterial!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_AnodeTargetMaterial, Target).good()){
}else
std::cerr << "Error: cannot access AnodeTargetMaterial!" << std::endl;
if (fileformat.getDataset()->findAndGetLongInt(DCM_BitsStored, BitsStored).good()){
}else
std::cerr << "Error: cannot access BitsStored!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_ViewPosition, ViewPosition).good()){
}else
std::cerr << "Error: cannot access ViewPosition!" << std::endl;
if (fileformat.getDataset()->findAndGetOFString(DCM_ImageLaterality, ImageLaterality).good()){
}else
std::cerr << "Error: cannot access ImageLaterality!" << std::endl;
}
}
void mammography::loadPixelData(const std::string fileName){
char strIn[1024];
strncpy(strIn, fileName.c_str(), sizeof(strIn));
strIn[sizeof(strIn) - 1] = 0;
DicomImage *image = new DicomImage(strIn);
if(image != NULL){
if (image->getStatus() == EIS_Normal){
if (image->isMonochrome()){
image->setMinMaxWindow();
const DiPixel* dipix = 0;
void* pixels = 0;
if(image){
dipix = image->getInterData();
pixels = (const_cast<DiPixel*>(dipix))->getDataPtr();
}
Uint16 *pixelData = (Uint16*)pixels;
for(int i = 0; i < int(image->getHeight())*int(image->getWidth()); i++){
pixelVec.push_back(pixelData[i]);
}
}
} else
std::cerr << "Error: cannot load DICOM image (" << DicomImage::getString(image->getStatus()) << ")" << std::endl;
}
delete image;
}