annotate OrthancStone/Sources/Toolbox/ImageGeometry.cpp @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Toolbox/ImageGeometry.cpp@30deba7bc8e2
children 4fb8fdf03314
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
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 507
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
182
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
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
27 #include <Images/ImageProcessing.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
28 #include <Logging.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
29 #include <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 {
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
79 int tmp = static_cast<int>(std::floor(extent.GetX1()));
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 x1 = 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 else
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 x1 = static_cast<unsigned int>(tmp);
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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
89 tmp = static_cast<int>(std::floor(extent.GetY1()));
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 y1 = 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 else
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 y1 = static_cast<unsigned int>(tmp);
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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
99 tmp = static_cast<int>(std::ceil(extent.GetX2()));
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 return false;
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 else if (static_cast<unsigned int>(tmp) >= targetWidth)
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 x2 = targetWidth - 1;
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 else
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 x2 = static_cast<unsigned int>(tmp);
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
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
113 tmp = static_cast<int>(std::ceil(extent.GetY2()));
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (tmp < 0)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 return false;
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 else if (static_cast<unsigned int>(tmp) >= targetHeight)
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 y2 = targetHeight - 1;
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 else
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 y2 = static_cast<unsigned int>(tmp);
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
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 return (x1 <= x2 &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 y1 <= y2);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
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 template <typename Reader,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 bool HasOffsetX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 bool HasOffsetY>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 static void ApplyAffineTransformToRow(typename Reader::PixelType* p,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 Reader& reader,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 unsigned int x1,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 unsigned int x2,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 float positionX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 float positionY,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 float offsetX,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 float offsetY)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 typename Reader::PixelType value;
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 for (unsigned int x = x1; x <= x2; x++, p++)
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 if (reader.GetValue(value, positionX, positionY))
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 *p = value;
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
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 if (HasOffsetX)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 positionX += offsetX;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
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 if (HasOffsetY)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 positionY += offsetY;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
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
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 template <Orthanc::PixelFormat Format,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 ImageInterpolation Interpolation>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 static void ApplyAffineInternal(Orthanc::ImageAccessor& target,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 const Orthanc::ImageAccessor& source,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
171 const Matrix& a,
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
172 bool clear)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 assert(target.GetFormat() == Format &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 source.GetFormat() == Format);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 typedef SubpixelReader<Format, Interpolation> Reader;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 typedef typename Reader::PixelType PixelType;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
180 if (clear)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 {
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
182 if (Format == Orthanc::PixelFormat_RGB24)
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
183 {
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
184 Orthanc::ImageProcessing::Set(target, 0, 0, 0, 255);
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
185 }
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
186 else
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
187 {
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
188 Orthanc::ImageProcessing::Set(target, 0);
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
189 }
182
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
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 Matrix inva;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 if (!LinearAlgebra::InvertMatrixUnsafe(inva, a))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 // Singular matrix
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 Reader reader(source);
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 unsigned int x1, y1, x2, y2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
203 if (GetProjectiveTransformExtent(x1, y1, x2, y2, a,
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 source.GetWidth(), source.GetHeight(),
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 target.GetWidth(), target.GetHeight()))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 const size_t targetPitch = target.GetPitch();
191
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
208 uint8_t *targetRow = reinterpret_cast<uint8_t*>
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
209 (reinterpret_cast<PixelType*>(target.GetRow(y1)) + x1);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 for (unsigned int y = y1; y <= y2; y++)
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 Vector start;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 LinearAlgebra::AssignVector(start, static_cast<double>(x1) + 0.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 start = boost::numeric::ublas::prod(inva, start);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 assert(LinearAlgebra::IsNear(1.0, start(2)));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 Vector offset;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 LinearAlgebra::AssignVector(offset, static_cast<double>(x1) + 1.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 offset = boost::numeric::ublas::prod(inva, offset) - start;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 assert(LinearAlgebra::IsNear(0.0, offset(2)));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 float startX = static_cast<float>(start[0]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 float startY = static_cast<float>(start[1]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 float offsetX = static_cast<float>(offset[0]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 float offsetY = static_cast<float>(offset[1]);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 PixelType* pixel = reinterpret_cast<PixelType*>(targetRow);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 if (LinearAlgebra::IsCloseToZero(offsetX))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 ApplyAffineTransformToRow<Reader, false, true>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 else if (LinearAlgebra::IsCloseToZero(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 ApplyAffineTransformToRow<Reader, true, false>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 else
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 ApplyAffineTransformToRow<Reader, true, true>
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 (pixel, reader, x1, x2, startX, startY, offsetX, offsetY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 targetRow += targetPitch;
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 }
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 void ApplyAffineTransform(Orthanc::ImageAccessor& target,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 const Orthanc::ImageAccessor& source,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 double a11,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 double a12,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 double b1,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 double a21,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 double a22,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 double b2,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
261 ImageInterpolation interpolation,
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
262 bool clear)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 if (source.GetFormat() != target.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 }
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 if (interpolation != ImageInterpolation_Nearest &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 interpolation != ImageInterpolation_Bilinear)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
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 Matrix a;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 a.resize(3, 3);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 a(0, 0) = a11;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 a(0, 1) = a12;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 a(0, 2) = b1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 a(1, 0) = a21;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 a(1, 1) = a22;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 a(1, 2) = b2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 a(2, 0) = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 a(2, 1) = 0;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 a(2, 2) = 1;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 switch (source.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 case Orthanc::PixelFormat_Grayscale8:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale8,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
294 ImageInterpolation_Nearest>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale8,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
299 ImageInterpolation_Bilinear>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 case Orthanc::PixelFormat_Grayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale16,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
312 ImageInterpolation_Nearest>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 ApplyAffineInternal<Orthanc::PixelFormat_Grayscale16,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
317 ImageInterpolation_Bilinear>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 case Orthanc::PixelFormat_SignedGrayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 ApplyAffineInternal<Orthanc::PixelFormat_SignedGrayscale16,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
330 ImageInterpolation_Nearest>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 case ImageInterpolation_Bilinear:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 ApplyAffineInternal<Orthanc::PixelFormat_SignedGrayscale16,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
335 ImageInterpolation_Bilinear>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
343 case Orthanc::PixelFormat_Float32:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
344 switch (interpolation)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
345 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
346 case ImageInterpolation_Nearest:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
347 ApplyAffineInternal<Orthanc::PixelFormat_Float32,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
348 ImageInterpolation_Nearest>(target, source, a, clear);
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
349 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
350
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
351 case ImageInterpolation_Bilinear:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
352 ApplyAffineInternal<Orthanc::PixelFormat_Float32,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
353 ImageInterpolation_Bilinear>(target, source, a, clear);
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
354 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
355
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
356 default:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
357 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
358 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
359 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
360
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 case Orthanc::PixelFormat_RGB24:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 case ImageInterpolation_Nearest:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 ApplyAffineInternal<Orthanc::PixelFormat_RGB24,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
366 ImageInterpolation_Nearest>(target, source, a, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 }
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 template <Orthanc::PixelFormat Format,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 ImageInterpolation Interpolation>
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
382 static void ApplyProjectiveInternal(Orthanc::ImageAccessor& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
383 const Orthanc::ImageAccessor& source,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
384 const Matrix& a,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
385 const Matrix& inva)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 assert(target.GetFormat() == Format &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 source.GetFormat() == Format);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 typedef SubpixelReader<Format, Interpolation> Reader;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 typedef typename Reader::PixelType PixelType;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 Reader reader(source);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 unsigned int x1, y1, x2, y2;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
507
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
396 const float floatWidth = static_cast<float>(source.GetWidth());
ce49eae4c887 Codegen + Warning fixes
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
397 const float floatHeight = static_cast<float>(source.GetHeight());
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
399 if (GetProjectiveTransformExtent(x1, y1, x2, y2, a,
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 source.GetWidth(), source.GetHeight(),
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 target.GetWidth(), target.GetHeight()))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 const size_t targetPitch = target.GetPitch();
191
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
404 uint8_t *targetRow = reinterpret_cast<uint8_t*>
46cb2eedc2e0 ShearWarpProjectiveTransform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 190
diff changeset
405 (reinterpret_cast<PixelType*>(target.GetRow(y1)) + x1);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 for (unsigned int y = y1; y <= y2; y++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 PixelType *p = reinterpret_cast<PixelType*>(targetRow);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 for (unsigned int x = x1; x <= x2; x++)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 Vector v;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 LinearAlgebra::AssignVector(v, static_cast<double>(x) + 0.5,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 static_cast<double>(y) + 0.5, 1);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 Vector vv = LinearAlgebra::Product(inva, v);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 assert(!LinearAlgebra::IsCloseToZero(vv[2]));
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 const double w = 1.0 / vv[2];
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 const float sourceX = static_cast<float>(vv[0] * w);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 const float sourceY = static_cast<float>(vv[1] * w);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 // Make sure no integer overflow will occur after truncation
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 // (the static_cast<unsigned int> could otherwise throw an
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
426 // exception in WebAssembly if strong projective effects)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 if (sourceX < floatWidth &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 sourceY < floatHeight)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 reader.GetValue(*p, sourceX, sourceY);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 }
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 p++;
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
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 targetRow += targetPitch;
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 }
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
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
442 void ApplyProjectiveTransform(Orthanc::ImageAccessor& target,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
443 const Orthanc::ImageAccessor& source,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
444 const Matrix& a,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
445 ImageInterpolation interpolation,
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
446 bool clear)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 if (source.GetFormat() != target.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
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
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 if (a.size1() != 3 ||
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 a.size2() != 3)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 if (interpolation != ImageInterpolation_Nearest &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 interpolation != ImageInterpolation_Bilinear)
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 // Check whether we are dealing with an affine transform
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 if (LinearAlgebra::IsCloseToZero(a(2, 0)) &&
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 LinearAlgebra::IsCloseToZero(a(2, 1)))
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 double w = a(2, 2);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 if (LinearAlgebra::IsCloseToZero(w))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
472 LOG(ERROR) << "Singular projective matrix";
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 else
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 ApplyAffineTransform(target, source,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 a(0, 0) / w, a(0, 1) / w, a(0, 2) / w,
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 a(1, 0) / w, a(1, 1) / w, a(1, 2) / w,
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
480 interpolation, clear);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
485 if (clear)
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 {
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
487 if (target.GetFormat() == Orthanc::PixelFormat_RGB24)
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
488 {
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
489 Orthanc::ImageProcessing::Set(target, 0, 0, 0, 255);
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
490 }
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
491 else
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
492 {
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
493 Orthanc::ImageProcessing::Set(target, 0);
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
494 }
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 }
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 Matrix inva;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 if (!LinearAlgebra::InvertMatrixUnsafe(inva, a))
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 return;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 }
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 switch (source.GetFormat())
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 case Orthanc::PixelFormat_Grayscale8:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
509 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale8,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
510 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
514 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale8,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
515 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 case Orthanc::PixelFormat_Grayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
527 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
528 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
532 ApplyProjectiveInternal<Orthanc::PixelFormat_Grayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
533 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 case Orthanc::PixelFormat_SignedGrayscale16:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
545 ApplyProjectiveInternal<Orthanc::PixelFormat_SignedGrayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
546 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 case ImageInterpolation_Bilinear:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
550 ApplyProjectiveInternal<Orthanc::PixelFormat_SignedGrayscale16,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
551 ImageInterpolation_Bilinear>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
559 case Orthanc::PixelFormat_Float32:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
560 switch (interpolation)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
561 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
562 case ImageInterpolation_Nearest:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
563 ApplyProjectiveInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
564 ImageInterpolation_Nearest>(target, source, a, inva);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
565 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
566
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
567 case ImageInterpolation_Bilinear:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
568 ApplyProjectiveInternal<Orthanc::PixelFormat_Float32,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
569 ImageInterpolation_Bilinear>(target, source, a, inva);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
570 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
571
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
572 default:
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
573 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
574 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
575 break;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 335
diff changeset
576
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 case Orthanc::PixelFormat_RGB24:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 switch (interpolation)
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 {
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 case ImageInterpolation_Nearest:
190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
581 ApplyProjectiveInternal<Orthanc::PixelFormat_RGB24,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 182
diff changeset
582 ImageInterpolation_Nearest>(target, source, a, inva);
182
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 }
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 break;
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 default:
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
2cbfb08f3a95 ImageGeometry.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 }
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 }