comparison Framework/Toolbox/DicomFrameConverter.cpp @ 32:517c46f527cd

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Dec 2016 11:00:23 +0100
parents ff1e935768e7
children 12987d11be33
comparison
equal deleted inserted replaced
31:9aace933cb64 32:517c46f527cd
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. 29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 **/ 30 **/
31 31
32 32
33 #include "DicomFrameConverter.h" 33 #include "DicomFrameConverter.h"
34
35 #include "GeometryToolbox.h"
34 36
35 #include "../../Resources/Orthanc/Core/Images/Image.h" 37 #include "../../Resources/Orthanc/Core/Images/Image.h"
36 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h" 38 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h"
37 #include "../../Resources/Orthanc/Core/OrthancException.h" 39 #include "../../Resources/Orthanc/Core/OrthancException.h"
38 #include "../../Resources/Orthanc/Core/Toolbox.h" 40 #include "../../Resources/Orthanc/Core/Toolbox.h"
69 return Orthanc::PixelFormat_Grayscale16; 71 return Orthanc::PixelFormat_Grayscale16;
70 } 72 }
71 } 73 }
72 74
73 75
74 void DicomFrameConverter::ReadParameters(const DicomDataset& dicom) 76 void DicomFrameConverter::ReadParameters(const OrthancPlugins::IDicomDataset& dicom)
75 { 77 {
76 SetDefaultParameters(); 78 SetDefaultParameters();
77 79
78 if (dicom.HasTag(DICOM_TAG_WINDOW_CENTER)) 80 Vector c, w;
81 if (GeometryToolbox::ParseVector(c, dicom, OrthancPlugins::DICOM_TAG_WINDOW_CENTER) &&
82 GeometryToolbox::ParseVector(c, dicom, OrthancPlugins::DICOM_TAG_WINDOW_WIDTH))
79 { 83 {
80 Vector c, w; 84 if (c.size() > 0 &&
81 dicom.GetVectorValue(c, DICOM_TAG_WINDOW_CENTER); 85 w.size() > 0)
82 dicom.GetVectorValue(w, DICOM_TAG_WINDOW_WIDTH);
83
84 if (c.size() > 0 && w.size() > 0)
85 { 86 {
86 defaultWindowCenter_ = static_cast<float>(c[0]); 87 defaultWindowCenter_ = static_cast<float>(c[0]);
87 defaultWindowWidth_ = static_cast<float>(w[0]); 88 defaultWindowWidth_ = static_cast<float>(w[0]);
88 } 89 }
89 } 90 }
90 91
91 isSigned_ = (dicom.GetIntegerValue(DICOM_TAG_PIXEL_REPRESENTATION) == 1); // Type 1 tag, must be present 92 OrthancPlugins::DicomDatasetReader reader(dicom);
92 93
93 if (dicom.HasTag(DICOM_TAG_RESCALE_INTERCEPT)) 94 int tmp;
95 if (!reader.GetIntegerValue(tmp, OrthancPlugins::DICOM_TAG_PIXEL_REPRESENTATION))
94 { 96 {
95 rescaleIntercept_ = dicom.GetFloatValue(DICOM_TAG_RESCALE_INTERCEPT); 97 // Type 1 tag, must be present
96 rescaleSlope_ = dicom.GetFloatValue(DICOM_TAG_RESCALE_SLOPE); 98 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
99 }
100
101 isSigned_ = (tmp == 1);
102
103 if (reader.GetFloatValue(rescaleIntercept_, OrthancPlugins::DICOM_TAG_RESCALE_INTERCEPT) &&
104 reader.GetFloatValue(rescaleSlope_, OrthancPlugins::DICOM_TAG_RESCALE_SLOPE))
105 {
97 hasRescale_ = true; 106 hasRescale_ = true;
98 } 107 }
99 108
100 std::string photometric = dicom.GetStringValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION); // Type 1 tag, must be present 109 // Type 1 tag, must be present
110 std::string photometric = reader.GetMandatoryStringValue(OrthancPlugins::DICOM_TAG_PHOTOMETRIC_INTERPRETATION);
101 photometric = Orthanc::Toolbox::StripSpaces(photometric); 111 photometric = Orthanc::Toolbox::StripSpaces(photometric);
102 isColor_ = (photometric != "MONOCHROME1" && 112 isColor_ = (photometric != "MONOCHROME1" &&
103 photometric != "MONOCHROME2"); 113 photometric != "MONOCHROME2");
104 } 114 }
105 115