SimpleITK  
sitkImageOperators.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef sitkImageOperators_h
19 #define sitkImageOperators_h
20 
21 #include "sitkAddImageFilter.h"
24 #include "sitkDivideImageFilter.h"
25 #include "sitkModulusImageFilter.h"
28 #include "sitkAndImageFilter.h"
29 #include "sitkOrImageFilter.h"
30 #include "sitkXorImageFilter.h"
31 
32 namespace itk::simple
33 {
34 
44 inline Image
45 operator+(const Image & img1, const Image & img2)
46 {
47  return Add(img1, img2);
48 }
49 inline Image
50 operator+(Image && img1, const Image & img2)
51 {
52  return Add(std::move(img1), img2);
53 }
54 inline Image
55 operator+(const Image & img, double s)
56 {
57  return Add(img, s);
58 }
59 inline Image
60 operator+(Image && img, double s)
61 {
62  return Add(std::move(img), s);
63 }
64 inline Image
65 operator+(double s, const Image & img)
66 {
67  return Add(s, img);
68 }
69 inline Image
70 operator-(const Image & img1, const Image & img2)
71 {
72  return Subtract(img1, img2);
73 }
74 inline Image
75 operator-(Image && img1, const Image & img2)
76 {
77  return Subtract(std::move(img1), img2);
78 }
79 inline Image
80 operator-(const Image & img, double s)
81 {
82  return Subtract(img, s);
83 }
84 inline Image
85 operator-(Image && img, double s)
86 {
87  return Subtract(std::move(img), s);
88 }
89 inline Image
90 operator-(double s, const Image & img)
91 {
92  return Subtract(s, img);
93 }
94 inline Image
95 operator*(const Image & img1, const Image & img2)
96 {
97  return Multiply(img1, img2);
98 }
99 inline Image
100 operator*(Image && img1, const Image & img2)
101 {
102  return Multiply(std::move(img1), img2);
103 }
104 inline Image
105 operator*(const Image & img, double s)
106 {
107  return Multiply(img, s);
108 }
109 inline Image
110 operator*(Image && img, double s)
111 {
112  return Multiply(std::move(img), s);
113 }
114 inline Image
115 operator*(double s, const Image & img)
116 {
117  return Multiply(s, img);
118 }
119 inline Image
120 operator/(const Image & img1, const Image & img2)
121 {
122  return Divide(img1, img2);
123 }
124 inline Image
125 operator/(Image && img1, const Image & img2)
126 {
127  return Divide(std::move(img1), img2);
128 }
129 inline Image
130 operator/(const Image & img, double s)
131 {
132  return Divide(img, s);
133 }
134 inline Image
135 operator/(Image && img, double s)
136 {
137  return Divide(std::move(img), s);
138 }
139 inline Image
140 operator/(double s, const Image & img)
141 {
142  return Divide(s, img);
143 }
144 inline Image
145 operator%(const Image & img1, const Image & img2)
146 {
147  return Modulus(img1, img2);
148 }
149 inline Image
150 operator%(Image && img1, const Image & img2)
151 {
152  return Modulus(std::move(img1), img2);
153 }
154 inline Image
155 operator%(const Image & img, uint32_t s)
156 {
157  return Modulus(img, s);
158 }
159 inline Image
160 operator%(Image && img, uint32_t s)
161 {
162  return Modulus(std::move(img), s);
163 }
164 inline Image
165 operator%(uint32_t s, const Image & img)
166 {
167  return Modulus(s, img);
168 }
169 
170 inline Image
171 operator-(const Image & img)
172 {
173  return UnaryMinus(img);
174 }
175 inline Image
177 {
178  return UnaryMinus(std::move(img));
179 }
180 
181 
182 inline Image
183 operator~(const Image & img)
184 {
185  return BitwiseNot(img);
186 }
187 inline Image
189 {
190  return BitwiseNot(std::move(img));
191 }
192 
193 inline Image
194 operator&(const Image & img1, const Image & img2)
195 {
196  return And(img1, img2);
197 }
198 inline Image
199 operator&(Image && img1, const Image & img2)
200 {
201  return And(std::move(img1), img2);
202 }
203 inline Image
204 operator&(const Image & img, int s)
205 {
206  return And(img, s);
207 }
208 inline Image
209 operator&(Image && img, int s)
210 {
211  return And(std::move(img), s);
212 }
213 inline Image
214 operator&(int s, const Image & img)
215 {
216  return And(s, img);
217 }
218 
219 inline Image
220 operator|(const Image & img1, const Image & img2)
221 {
222  return Or(img1, img2);
223 }
224 inline Image
225 operator|(Image && img1, const Image & img2)
226 {
227  return Or(std::move(img1), img2);
228 }
229 inline Image
230 operator|(const Image & img, int s)
231 {
232  return Or(img, s);
233 }
234 inline Image
235 operator|(Image && img, int s)
236 {
237  return Or(std::move(img), s);
238 }
239 inline Image
240 operator|(int s, const Image & img)
241 {
242  return Or(s, img);
243 }
244 
245 inline Image
246 operator^(const Image & img1, const Image & img2)
247 {
248  return Xor(img1, img2);
249 }
250 inline Image
251 operator^(Image && img1, const Image & img2)
252 {
253  return Xor(std::move(img1), img2);
254 }
255 inline Image
256 operator^(const Image & img, int s)
257 {
258  return Xor(img, s);
259 }
260 inline Image
261 operator^(Image && img, int s)
262 {
263  return Xor(std::move(img), s);
264 }
265 inline Image
266 operator^(int s, const Image & img)
267 {
268  return Xor(s, img);
269 }
270 
271 
272 inline Image &
273 operator+=(Image & img1, const Image & img2)
274 {
275  Add(img1.ProxyForInPlaceOperation(), img2);
276  return img1;
277 }
278 inline Image &
279 operator+=(Image & img1, double s)
280 {
281  Add(img1.ProxyForInPlaceOperation(), s);
282  return img1;
283 }
284 inline Image &
285 operator-=(Image & img1, const Image & img2)
286 {
287  Subtract(img1.ProxyForInPlaceOperation(), img2);
288  return img1;
289 }
290 inline Image &
291 operator-=(Image & img1, double s)
292 {
294  return img1;
295 }
296 inline Image &
297 operator*=(Image & img1, const Image & img2)
298 {
299  Multiply(img1.ProxyForInPlaceOperation(), img2);
300  return img1;
301 }
302 inline Image &
303 operator*=(Image & img1, double s)
304 {
306  return img1;
307 }
308 inline Image &
309 operator/=(Image & img1, const Image & img2)
310 {
311  Divide(img1.ProxyForInPlaceOperation(), img2);
312  return img1;
313 }
314 inline Image &
315 operator/=(Image & img1, double s)
316 {
317  Divide(img1.ProxyForInPlaceOperation(), s);
318  return img1;
319 }
320 inline Image &
321 operator%=(Image & img1, const Image & img2)
322 {
323  Modulus(img1.ProxyForInPlaceOperation(), img2);
324  return img1;
325 }
326 inline Image &
327 operator%=(Image & img1, uint32_t s)
328 {
330  return img1;
331 }
332 inline Image &
333 operator&=(Image & img1, const Image & img2)
334 {
335  And(img1.ProxyForInPlaceOperation(), img2);
336  return img1;
337 }
338 inline Image &
339 operator&=(Image & img1, int s)
340 {
341  And(img1.ProxyForInPlaceOperation(), s);
342  return img1;
343 }
344 inline Image &
345 operator|=(Image & img1, const Image & img2)
346 {
347  Or(img1.ProxyForInPlaceOperation(), img2);
348  return img1;
349 }
350 inline Image &
351 operator|=(Image & img1, int s)
352 {
353  Or(img1.ProxyForInPlaceOperation(), s);
354  return img1;
355 }
356 inline Image &
357 operator^=(Image & img1, const Image & img2)
358 {
359  Xor(img1.ProxyForInPlaceOperation(), img2);
360  return img1;
361 }
362 inline Image &
363 operator^=(Image & img1, int s)
364 {
365  Xor(img1.ProxyForInPlaceOperation(), s);
366  return img1;
367 }
369 } // namespace itk::simple
370 
371 #endif // sitkImageOperators_h
itk::simple::Image
The Image class for SimpleITK.
Definition: sitkImage.h:76
itk::simple::operator|=
Image & operator|=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:345
itk::simple::Modulus
Image Modulus(Image &&image1, const Image &image2)
Computes the modulus (x % dividend) pixel-wise.
itk::simple::operator%
Image operator%(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:145
sitkBitwiseNotImageFilter.h
sitkAddImageFilter.h
itk::simple::Subtract
Image Subtract(Image &&image1, const Image &image2)
Pixel-wise subtraction of two images.
itk::simple::operator|
Image operator|(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:220
itk::simple::operator^=
Image & operator^=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:357
itk::simple::Or
Image Or(Image &&image1, const Image &image2)
Implements the OR bitwise operator pixel-wise between two images.
itk::simple::operator~
Image operator~(const Image &img)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:183
itk::simple::operator^
Image operator^(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:246
itk::simple::Add
Image Add(Image &&image1, const Image &image2)
Pixel-wise addition of two images.
itk::simple::Xor
Image Xor(Image &&image1, const Image &image2)
Computes the XOR bitwise operator pixel-wise between two images.
itk::simple::operator*=
Image & operator*=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:297
sitkUnaryMinusImageFilter.h
itk::simple::BitwiseNot
Image BitwiseNot(Image &&image1)
Implements pixel-wise generic operation on one image.
itk::simple::Multiply
Image Multiply(Image &&image1, const Image &image2)
Pixel-wise multiplication of two images.
itk::simple::operator&=
Image & operator&=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:333
sitkSubtractImageFilter.h
sitkMultiplyImageFilter.h
itk::simple::Divide
Image Divide(Image &&image1, const Image &image2)
Pixel-wise division of two images.
sitkDivideImageFilter.h
itk::simple::operator/
Image operator/(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:120
itk::simple::operator/=
Image & operator/=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:309
itk::simple::And
Image And(Image &&image1, const Image &image2)
Implements the AND bitwise operator pixel-wise between two images.
itk::simple::operator&
Image operator&(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:194
itk::simple::Image::ProxyForInPlaceOperation
Image ProxyForInPlaceOperation()
Advanced method not commonly needed.
itk::simple::operator%=
Image & operator%=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:321
sitkOrImageFilter.h
sitkXorImageFilter.h
itk::simple::operator-=
Image & operator-=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:285
sitkModulusImageFilter.h
itk::simple::operator+=
Image & operator+=(Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:273
itk::Image
Definition: sitkPixelIDTypes.h:28
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::UnaryMinus
Image UnaryMinus(Image &&image1)
Implements pixel-wise generic operation on one image.
sitkAndImageFilter.h
itk::simple::operator-
Image operator-(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:70
itk::simple::operator+
Image operator+(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:45
itk::simple::operator*
Image operator*(const Image &img1, const Image &img2)
Performs the operator on a per pixel basis.
Definition: sitkImageOperators.h:95