annotate Framework/Toolbox/ImageGeometry.cpp @ 338:b3b3fa0e3689 am-2

BitmapStack
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Oct 2018 12:50:38 +0200
parents 3e42fc27eb91
children f5d5814a41a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "ImageGeometry.h"
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "Extent2D.h"
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "SubpixelReader.h"
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
27 #include <Core/Images/ImageProcessing.h>
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
28 #include <Core/Logging.h>
335
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
29 #include <Core/OrthancException.h>
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace OrthancStone
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 static void AddTransformedPoint(Extent2D& extent,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 const Matrix& a,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 double x,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 double y)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 assert(a.size1() == 3 &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 a.size2() == 3);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 Vector p = LinearAlgebra::Product(a, LinearAlgebra::CreateVector(x, y, 1));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 if (!LinearAlgebra::IsCloseToZero(p[2]))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 extent.AddPoint(p[0] / p[2], p[1] / p[2]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
51 bool GetProjectiveTransformExtent(unsigned int& x1,
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 unsigned int& y1,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 unsigned int& x2,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 unsigned int& y2,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 const Matrix& a,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 unsigned int sourceWidth,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 unsigned int sourceHeight,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 unsigned int targetWidth,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 unsigned int targetHeight)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (targetWidth == 0 ||
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 targetHeight == 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return false;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Extent2D extent;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 AddTransformedPoint(extent, a, 0, 0);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 AddTransformedPoint(extent, a, sourceWidth, 0);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 AddTransformedPoint(extent, a, 0, sourceHeight);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 AddTransformedPoint(extent, a, sourceWidth, sourceHeight);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 if (extent.IsEmpty())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return false;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 int tmp;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 tmp = std::floor(extent.GetX1());
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 x1 = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 x1 = static_cast<unsigned int>(tmp);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 tmp = std::floor(extent.GetY1());
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 y1 = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 y1 = static_cast<unsigned int>(tmp);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 tmp = std::ceil(extent.GetX2());
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 return false;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 else if (static_cast<unsigned int>(tmp) >= targetWidth)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 x2 = targetWidth - 1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 x2 = static_cast<unsigned int>(tmp);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 tmp = std::ceil(extent.GetY2());
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 return false;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 else if (static_cast<unsigned int>(tmp) >= targetHeight)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 y2 = targetHeight - 1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 y2 = static_cast<unsigned int>(tmp);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 return (x1 <= x2 &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 y1 <= y2);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 template <typename Reader,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 bool HasOffsetX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 bool HasOffsetY>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 static void ApplyAffineTransformToRow(typename Reader::PixelType* p,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 Reader& reader,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 unsigned int x1,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 unsigned int x2,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 float positionX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 float positionY,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 float offsetX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 float offsetY)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 typename Reader::PixelType value;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 for (unsigned int x = x1; x <= x2; x++, p++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 if (reader.GetValue(value, positionX, positionY))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 *p = value;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 Reader::Traits::SetZero(*p);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 if (HasOffsetX)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 positionX += offsetX;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 if (HasOffsetY)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 positionY += offsetY;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 template <Orthanc::PixelFormat Format,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 ImageInterpolation Interpolation>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 static void ApplyAffineInternal(Orthanc::ImageAccessor& target,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 const Orthanc::ImageAccessor& source,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 const Matrix& a)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 assert(target.GetFormat() == Format &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 source.GetFormat() == Format);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 typedef SubpixelReader<Format, Interpolation> Reader;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 typedef typename Reader::PixelType PixelType;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 if (Format == Orthanc::PixelFormat_RGB24)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 Orthanc::ImageProcessing::Set(target, 0, 0, 0, 255);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 Orthanc::ImageProcessing::Set(target, 0);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 Matrix inva;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 if (!LinearAlgebra::InvertMatrixUnsafe(inva, a))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 // Singular matrix
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 Reader reader(source);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 unsigned int x1, y1, x2, y2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
205 if (GetProjectiveTransformExtent(x1, y1, x2, y2, a,
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 source.GetWidth(), source.GetHeight(),
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 target.GetWidth(), target.GetHeight()))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 const size_t targetPitch = target.GetPitch();
191
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
210 uint8_t *targetRow = reinterpret_cast<uint8_t*>
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
211 (reinterpret_cast<PixelType*>(target.GetRow(y1)) + x1);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 for (unsigned int y = y1; y <= y2; y++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 Vector start;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 LinearAlgebra::AssignVector(start, static_cast<double>(x1) + 0.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 start = boost::numeric::ublas::prod(inva, start);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 assert(LinearAlgebra::IsNear(1.0, start(2)));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 Vector offset;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 LinearAlgebra::AssignVector(offset, static_cast<double>(x1) + 1.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 offset = boost::numeric::ublas::prod(inva, offset) - start;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 assert(LinearAlgebra::IsNear(0.0, offset(2)));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 float startX = static_cast<float>(start[0]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 float startY = static_cast<float>(start[1]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 float offsetX = static_cast<float>(offset[0]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 float offsetY = static_cast<float>(offset[1]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 PixelType* pixel = reinterpret_cast<PixelType*>(targetRow);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 if (LinearAlgebra::IsCloseToZero(offsetX))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 ApplyAffineTransformToRow<Reader, false, true>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 else if (LinearAlgebra::IsCloseToZero(offsetY))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 ApplyAffineTransformToRow<Reader, true, false>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 ApplyAffineTransformToRow<Reader, true, true>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 targetRow += targetPitch;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 void ApplyAffineTransform(Orthanc::ImageAccessor& target,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 const Orthanc::ImageAccessor& source,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 double a11,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 double a12,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 double b1,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 double a21,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 double a22,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 double b2,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 ImageInterpolation interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 if (source.GetFormat() != target.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 if (interpolation != ImageInterpolation_Nearest &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 interpolation != ImageInterpolation_Bilinear)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 Matrix a;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 a.resize(3, 3);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 a(0, 0) = a11;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 a(0, 1) = a12;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 a(0, 2) = b1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 a(1, 0) = a21;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 a(1, 1) = a22;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 a(1, 2) = b2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 a(2, 0) = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 a(2, 1) = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 a(2, 2) = 1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 switch (source.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 case Orthanc::PixelFormat_Grayscale8:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale8,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 ImageInterpolation_Nearest>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale8,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 ImageInterpolation_Bilinear>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 case Orthanc::PixelFormat_Grayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale16,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 ImageInterpolation_Nearest>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale16,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 ImageInterpolation_Bilinear>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 case Orthanc::PixelFormat_SignedGrayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 ApplyAffineInternal<Orthanc::PixelFormat_SignedGrayscale16,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 ImageInterpolation_Nearest>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 ApplyAffineInternal<Orthanc::PixelFormat_SignedGrayscale16,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 ImageInterpolation_Bilinear>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
344 case Orthanc::PixelFormat_Float32:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
345 switch (interpolation)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
346 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
347 case ImageInterpolation_Nearest:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
348 ApplyAffineInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
349 ImageInterpolation_Nearest>(target, source, a);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
350 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
351
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
352 case ImageInterpolation_Bilinear:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
353 ApplyAffineInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
354 ImageInterpolation_Bilinear>(target, source, a);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
355 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
356
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
357 default:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
358 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
359 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
360 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
361
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 case Orthanc::PixelFormat_RGB24:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 ApplyAffineInternal<Orthanc::PixelFormat_RGB24,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 ImageInterpolation_Nearest>(target, source, a);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 template <Orthanc::PixelFormat Format,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 ImageInterpolation Interpolation>
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
383 static void ApplyProjectiveInternal(Orthanc::ImageAccessor& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
384 const Orthanc::ImageAccessor& source,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
385 const Matrix& a,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
386 const Matrix& inva)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 assert(target.GetFormat() == Format &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 source.GetFormat() == Format);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 typedef SubpixelReader<Format, Interpolation> Reader;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 typedef typename Reader::PixelType PixelType;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 Reader reader(source);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 unsigned int x1, y1, x2, y2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 const float floatWidth = source.GetWidth();
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 const float floatHeight = source.GetHeight();
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
400 if (GetProjectiveTransformExtent(x1, y1, x2, y2, a,
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 source.GetWidth(), source.GetHeight(),
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 target.GetWidth(), target.GetHeight()))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 const size_t targetPitch = target.GetPitch();
191
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
405 uint8_t *targetRow = reinterpret_cast<uint8_t*>
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
406 (reinterpret_cast<PixelType*>(target.GetRow(y1)) + x1);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 for (unsigned int y = y1; y <= y2; y++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 PixelType *p = reinterpret_cast<PixelType*>(targetRow);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 for (unsigned int x = x1; x <= x2; x++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 Vector v;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 LinearAlgebra::AssignVector(v, static_cast<double>(x) + 0.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 Vector vv = LinearAlgebra::Product(inva, v);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 assert(!LinearAlgebra::IsCloseToZero(vv[2]));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 const double w = 1.0 / vv[2];
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 const float sourceX = static_cast<float>(vv[0] * w);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 const float sourceY = static_cast<float>(vv[1] * w);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 // Make sure no integer overflow will occur after truncation
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 // (the static_cast<unsigned int> could otherwise throw an
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
427 // exception in WebAssembly if strong projective effects)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 if (sourceX < floatWidth &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 sourceY < floatHeight)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 reader.GetValue(*p, sourceX, sourceY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 Reader::Traits::SetZero(*p);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 p++;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 targetRow += targetPitch;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
447 void ApplyProjectiveTransform(Orthanc::ImageAccessor& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
448 const Orthanc::ImageAccessor& source,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
449 const Matrix& a,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
450 ImageInterpolation interpolation)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 if (source.GetFormat() != target.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 if (a.size1() != 3 ||
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 a.size2() != 3)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 if (interpolation != ImageInterpolation_Nearest &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 interpolation != ImageInterpolation_Bilinear)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 // Check whether we are dealing with an affine transform
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 if (LinearAlgebra::IsCloseToZero(a(2, 0)) &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 LinearAlgebra::IsCloseToZero(a(2, 1)))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 double w = a(2, 2);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 if (LinearAlgebra::IsCloseToZero(w))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 {
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
476 LOG(ERROR) << "Singular projective matrix";
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 ApplyAffineTransform(target, source,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 a(0, 0) / w, a(0, 1) / w, a(0, 2) / w,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 a(1, 0) / w, a(1, 1) / w, a(1, 2) / w,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 interpolation);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 if (target.GetFormat() == Orthanc::PixelFormat_RGB24)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 Orthanc::ImageProcessing::Set(target, 0, 0, 0, 255);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 Orthanc::ImageProcessing::Set(target, 0);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 Matrix inva;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 if (!LinearAlgebra::InvertMatrixUnsafe(inva, a))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 switch (source.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 case Orthanc::PixelFormat_Grayscale8:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
510 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale8,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
511 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
515 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale8,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
516 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 case Orthanc::PixelFormat_Grayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
528 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
529 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
533 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
534 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 case Orthanc::PixelFormat_SignedGrayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
546 ApplyProjectiveInternal<Orthanc::PixelFormat_SignedGrayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
547 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
551 ApplyProjectiveInternal<Orthanc::PixelFormat_SignedGrayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
552 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
560 case Orthanc::PixelFormat_Float32:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
561 switch (interpolation)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
562 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
563 case ImageInterpolation_Nearest:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
564 ApplyProjectiveInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
565 ImageInterpolation_Nearest>(target, source, a, inva);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
566 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
567
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
568 case ImageInterpolation_Bilinear:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
569 ApplyProjectiveInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
570 ImageInterpolation_Bilinear>(target, source, a, inva);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
571 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
572
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
573 default:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
574 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
575 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
576 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
577
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 case Orthanc::PixelFormat_RGB24:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
582 ApplyProjectiveInternal<Orthanc::PixelFormat_RGB24,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
583 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 }