comparison OrthancFramework/Sources/Images/ImageProcessing.h @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Core/Images/ImageProcessing.h@f9863630ec7f
children 55727d85f419
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
11 *
12 * In addition, as a special exception, the copyright holders of this
13 * program give permission to link the code of its release with the
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
15 * that use the same license as the "OpenSSL" library), and distribute
16 * the linked executables. You must obey the GNU General Public License
17 * in all respects for all of the code used other than "OpenSSL". If you
18 * modify file(s) with this exception, you may extend this exception to
19 * your version of the file(s), but you are not obligated to do so. If
20 * you do not wish to do so, delete this exception statement from your
21 * version. If you delete this exception statement from all source files
22 * in the program, then also delete it here.
23 *
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 **/
32
33
34 #pragma once
35
36 #include "../OrthancFramework.h"
37
38 #include "ImageAccessor.h"
39 #include <vector>
40
41 #include <stdint.h>
42 #include <algorithm>
43 #include <boost/noncopyable.hpp>
44
45 namespace Orthanc
46 {
47 class ORTHANC_PUBLIC ImageProcessing : public boost::noncopyable
48 {
49 public:
50 class ImagePoint
51 {
52 int32_t x_;
53 int32_t y_;
54
55 public:
56 ImagePoint(int32_t x, int32_t y)
57 : x_(x),
58 y_(y)
59 {
60 }
61
62 int32_t GetX() const {return x_;}
63
64 int32_t GetY() const {return y_;}
65
66 void Set(int32_t x, int32_t y)
67 {
68 x_ = x;
69 y_ = y;
70 }
71
72 void ClipTo(int32_t minX, int32_t maxX, int32_t minY, int32_t maxY)
73 {
74 x_ = std::max(minX, std::min(maxX, x_));
75 y_ = std::max(minY, std::min(maxY, y_));
76 }
77
78 double GetDistanceTo(const ImagePoint& other) const;
79
80 double GetDistanceToLine(double a, double b, double c) const; // where ax + by + c = 0 is the equation of the line
81 };
82
83 static void Copy(ImageAccessor& target,
84 const ImageAccessor& source);
85
86 static void Convert(ImageAccessor& target,
87 const ImageAccessor& source);
88
89 static void ApplyWindowing_Deprecated(ImageAccessor& target,
90 const ImageAccessor& source,
91 float windowCenter,
92 float windowWidth,
93 float rescaleSlope,
94 float rescaleIntercept,
95 bool invert);
96
97 static void Set(ImageAccessor& image,
98 int64_t value);
99
100 static void Set(ImageAccessor& image,
101 uint8_t red,
102 uint8_t green,
103 uint8_t blue,
104 uint8_t alpha);
105
106 static void Set(ImageAccessor& image,
107 uint8_t red,
108 uint8_t green,
109 uint8_t blue,
110 ImageAccessor& alpha);
111
112 static void ShiftRight(ImageAccessor& target,
113 unsigned int shift);
114
115 static void ShiftLeft(ImageAccessor& target,
116 unsigned int shift);
117
118 static void GetMinMaxIntegerValue(int64_t& minValue,
119 int64_t& maxValue,
120 const ImageAccessor& image);
121
122 static void GetMinMaxFloatValue(float& minValue,
123 float& maxValue,
124 const ImageAccessor& image);
125
126 static void AddConstant(ImageAccessor& image,
127 int64_t value);
128
129 // "useRound" is expensive
130 static void MultiplyConstant(ImageAccessor& image,
131 float factor,
132 bool useRound);
133
134 // Computes "(x + offset) * scaling" inplace. "useRound" is expensive.
135 static void ShiftScale(ImageAccessor& image,
136 float offset,
137 float scaling,
138 bool useRound);
139
140 static void ShiftScale(ImageAccessor& target,
141 const ImageAccessor& source,
142 float offset,
143 float scaling,
144 bool useRound);
145
146 static void Invert(ImageAccessor& image);
147
148 static void Invert(ImageAccessor& image, int64_t maxValue);
149
150 static void DrawLineSegment(ImageAccessor& image,
151 int x0,
152 int y0,
153 int x1,
154 int y1,
155 int64_t value);
156
157 static void DrawLineSegment(ImageAccessor& image,
158 int x0,
159 int y0,
160 int x1,
161 int y1,
162 uint8_t red,
163 uint8_t green,
164 uint8_t blue,
165 uint8_t alpha);
166
167 static void FillPolygon(ImageAccessor& image,
168 const std::vector<ImagePoint>& points,
169 int64_t value);
170
171 static void Resize(ImageAccessor& target,
172 const ImageAccessor& source);
173
174 static ImageAccessor* Halve(const ImageAccessor& source,
175 bool forceMinimalPitch);
176
177 static void FlipX(ImageAccessor& image);
178
179 static void FlipY(ImageAccessor& image);
180
181 static void SeparableConvolution(ImageAccessor& image /* inplace */,
182 const std::vector<float>& horizontal,
183 size_t horizontalAnchor,
184 const std::vector<float>& vertical,
185 size_t verticalAnchor);
186
187 static void SmoothGaussian5x5(ImageAccessor& image);
188
189 static void FitSize(ImageAccessor& target,
190 const ImageAccessor& source);
191
192 static ImageAccessor* FitSize(const ImageAccessor& source,
193 unsigned int width,
194 unsigned int height);
195 };
196 }
197