Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoding/Plugin.cpp @ 1398:aa9b8fa97576
fix for msvc
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 12:47:49 +0200 |
parents | 3d76e26b3865 |
children | da7854deb662 |
rev | line source |
---|---|
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
9 * License, or (at your option) any later version. |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
10 * |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
14 * General Public License for more details. |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 **/ |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 #include <map> |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include <string> |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include <stdexcept> |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <sstream> |
1040
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
25 #include <boost/lexical_cast.hpp> |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "OrthancContext.h" |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "../../../Core/ImageFormats/ImageProcessing.h" |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include <gdcmReader.h> |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include <gdcmImageReader.h> |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
32 #include <gdcmImageChangePlanarConfiguration.h> |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
33 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
34 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
35 static void AnswerUnsupportedImage(OrthancPluginRestOutput* output) |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
36 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
37 OrthancContext::GetInstance().Redirect(output, "/app/images/unsupported.png"); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
38 } |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 static bool GetOrthancPixelFormat(Orthanc::PixelFormat& format, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 const gdcm::Image& image) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 if (image.GetPlanarConfiguration() != 0 && |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 image.GetPixelFormat().GetSamplesPerPixel() != 1) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 OrthancContext::GetInstance().LogError("Planar configurations are not supported"); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 return false; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 if (image.GetPixelFormat().GetSamplesPerPixel() == 1) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 switch (image.GetPixelFormat().GetScalarType()) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 case gdcm::PixelFormat::UINT8: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 format = Orthanc::PixelFormat_Grayscale8; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 return true; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 case gdcm::PixelFormat::UINT16: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 format = Orthanc::PixelFormat_Grayscale16; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 return true; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 case gdcm::PixelFormat::INT16: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 format = Orthanc::PixelFormat_SignedGrayscale16; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 return true; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 default: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 return false; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 else if (image.GetPixelFormat().GetSamplesPerPixel() == 3 && |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 image.GetPixelFormat().GetScalarType() == gdcm::PixelFormat::UINT8) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 format = Orthanc::PixelFormat_RGB24; |
985 | 75 return true; |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 else if (image.GetPixelFormat().GetSamplesPerPixel() == 4 && |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 image.GetPixelFormat().GetScalarType() == gdcm::PixelFormat::UINT8) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 format = Orthanc::PixelFormat_RGBA32; |
985 | 81 return true; |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
985 | 83 |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 return false; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 ORTHANC_PLUGINS_API int32_t DecodeImage(OrthancPluginRestOutput* output, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 const char* url, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 const OrthancPluginHttpRequest* request) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 std::string instance(request->groups[0]); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 std::string outputFormat(request->groups[1]); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 OrthancContext::GetInstance().LogWarning("Using GDCM to decode instance " + instance); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 // Download the request DICOM instance from Orthanc into a memory buffer |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 std::string dicom; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 OrthancContext::GetInstance().GetDicomForInstance(dicom, instance); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 // Prepare a memory stream over the DICOM instance |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 std::stringstream stream(dicom); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 // Parse the DICOM instance using GDCM |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 gdcm::ImageReader imageReader; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 imageReader.SetStream(stream); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 if (!imageReader.Read()) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 OrthancContext::GetInstance().LogError("GDCM cannot extract an image from this DICOM instance"); |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
109 AnswerUnsupportedImage(output); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
110 return 0; |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 gdcm::Image& image = imageReader.GetImage(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
115 |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 // Log information about the decoded image |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 char tmp[1024]; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 sprintf(tmp, "Image format: %dx%d %s with %d color channel(s)", image.GetRows(), image.GetColumns(), |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 image.GetPixelFormat().GetScalarTypeAsString(), image.GetPixelFormat().GetSamplesPerPixel()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 OrthancContext::GetInstance().LogWarning(tmp); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
122 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
123 // Convert planar configuration |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
124 gdcm::ImageChangePlanarConfiguration planar; |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
125 if (image.GetPlanarConfiguration() != 0 && |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
126 image.GetPixelFormat().GetSamplesPerPixel() != 1) |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
127 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
128 OrthancContext::GetInstance().LogWarning("Converting planar configuration to interleaved"); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
129 planar.SetInput(imageReader.GetImage()); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
130 planar.Change(); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
131 image = planar.GetOutput(); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
132 } |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
133 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
134 |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 // Create a read-only accessor to the bitmap decoded by GDCM |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 Orthanc::PixelFormat format; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 if (!GetOrthancPixelFormat(format, image)) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 OrthancContext::GetInstance().LogError("This sample plugin does not support this image format"); |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
140 AnswerUnsupportedImage(output); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
141 return 0; |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 Orthanc::ImageAccessor decodedImage; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 std::vector<char> decodedBuffer(image.GetBufferLength()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 if (decodedBuffer.size()) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 image.GetBuffer(&decodedBuffer[0]); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 unsigned int pitch = image.GetColumns() * ::Orthanc::GetBytesPerPixel(format); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 decodedImage.AssignWritable(format, image.GetColumns(), image.GetRows(), pitch, &decodedBuffer[0]); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 else |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 // Empty image |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 decodedImage.AssignWritable(format, 0, 0, 0, NULL); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 // Convert the pixel format from GDCM to the format requested by the REST query |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 Orthanc::ImageBuffer converted; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 converted.SetWidth(decodedImage.GetWidth()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 converted.SetHeight(decodedImage.GetHeight()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 if (outputFormat == "preview") |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 if (format == Orthanc::PixelFormat_RGB24 || |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 format == Orthanc::PixelFormat_RGBA32) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 // Do not rescale color image |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 converted.SetFormat(Orthanc::PixelFormat_RGB24); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 else |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 converted.SetFormat(Orthanc::PixelFormat_Grayscale8); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 // Rescale the image to the [0,255] range |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 int64_t a, b; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 Orthanc::ImageProcessing::GetMinMaxValue(a, b, decodedImage); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 float offset = -a; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 float scaling = 255.0f / static_cast<float>(b - a); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 Orthanc::ImageProcessing::ShiftScale(decodedImage, offset, scaling); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 else |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 { |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
188 if (format == Orthanc::PixelFormat_RGB24 || |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
189 format == Orthanc::PixelFormat_RGBA32) |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
190 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
191 // Do not convert color images to grayscale values (this is Orthanc convention) |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
192 AnswerUnsupportedImage(output); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
193 return 0; |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
194 } |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
195 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
196 if (outputFormat == "image-uint8") |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
197 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
198 converted.SetFormat(Orthanc::PixelFormat_Grayscale8); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
199 } |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
200 else if (outputFormat == "image-uint16") |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
201 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
202 converted.SetFormat(Orthanc::PixelFormat_Grayscale16); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
203 } |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
204 else if (outputFormat == "image-int16") |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
205 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
206 converted.SetFormat(Orthanc::PixelFormat_SignedGrayscale16); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
207 } |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
208 else |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
209 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
210 OrthancContext::GetInstance().LogError("Unknown output format: " + outputFormat); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
211 AnswerUnsupportedImage(output); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
212 return 0; |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
985
diff
changeset
|
213 } |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 Orthanc::ImageAccessor convertedAccessor(converted.GetAccessor()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 Orthanc::ImageProcessing::Convert(convertedAccessor, decodedImage); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 // Compress the converted image as a PNG file |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 OrthancContext::GetInstance().CompressAndAnswerPngImage(output, convertedAccessor); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 return 0; // Success |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 extern "C" |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 OrthancContext::GetInstance().Initialize(context); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 OrthancContext::GetInstance().LogWarning("Initializing GDCM decoding"); |
1040
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
232 |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
233 // Check the version of the Orthanc core |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
234 if (OrthancPluginCheckVersion(context) == 0) |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
235 { |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
236 OrthancContext::GetInstance().LogError( |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
237 "Your version of Orthanc (" + std::string(context->orthancVersion) + |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
238 ") must be above " + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER) + |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
239 "." + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER) + |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
240 "." + boost::lexical_cast<std::string>(ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER) + |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
241 " to run this plugin"); |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
242 return -1; |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
243 } |
d06186cdc502
check plugin version in samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
993
diff
changeset
|
244 |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 OrthancContext::GetInstance().Register("/instances/([^/]+)/(preview|image-uint8|image-uint16|image-int16)", DecodeImage); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 return 0; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 OrthancContext::GetInstance().LogWarning("Finalizing GDCM decoding"); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 OrthancContext::GetInstance().Finalize(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 return "gdcm-decoding"; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 return "1.0"; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 } |