File tree Expand file tree Collapse file tree 4 files changed +65
-3
lines changed Expand file tree Collapse file tree 4 files changed +65
-3
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,13 @@ Create a Size
7
7
Synopsis
8
8
--------
9
9
10
-
11
10
Create a itk::Size, which represents the size of a region in an itk::Image.
12
11
13
-
14
12
Results
15
13
-------
16
14
17
15
Output::
16
+
18
17
[0, 0]
19
18
[1, 2]
20
19
Original file line number Diff line number Diff line change @@ -13,11 +13,17 @@ install( TARGETS IsPixelInsideRegion
13
13
COMPONENT Runtime
14
14
)
15
15
16
- install ( FILES Code.cxx CMakeLists.txt
16
+ install ( FILES Code.cxx Code.py CMakeLists.txt
17
17
DESTINATION share/ITKExamples/Code/Core/Common/IsPixelInsideRegion
18
18
COMPONENT Code
19
19
)
20
20
21
21
enable_testing ()
22
22
add_test ( NAME IsPixelInsideRegionTest
23
23
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /IsPixelInsideRegion )
24
+
25
+ if (ITK_WRAP_PYTHON )
26
+ add_test (NAME IsPixelInsideRegionPython
27
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /Code.py
28
+ )
29
+ endif ()
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
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
+ import itk
18
+
19
+ Dimension = 2
20
+
21
+ SizeType = itk .Size [Dimension ]
22
+ size = SizeType ()
23
+ size .Fill (3 )
24
+
25
+ IndexType = itk .Index [Dimension ]
26
+ start = IndexType ()
27
+ start .Fill (0 )
28
+
29
+ RegionType = itk .ImageRegion [Dimension ]
30
+ region = RegionType (start , size )
31
+
32
+ testPixel1 = IndexType ()
33
+ testPixel1 [0 ] = 1
34
+ testPixel1 [1 ] = 1
35
+
36
+ testPixel2 = IndexType ()
37
+ testPixel2 [0 ] = 6
38
+ testPixel2 [1 ] = 6
39
+
40
+ print (testPixel1 , end = " " )
41
+ if region .IsInside (testPixel1 ):
42
+ print ("Inside" )
43
+ else :
44
+ print ("Outside" )
45
+
46
+ print (testPixel2 , end = " " )
47
+ if region .IsInside (testPixel2 ):
48
+ print ("Inside" )
49
+ else :
50
+ print ("Outside" )
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ Output::
25
25
Code
26
26
----
27
27
28
+ Python
29
+ ......
30
+
31
+ .. literalinclude :: Code.py
32
+ :language: python
33
+ :lines: 1, 16-
34
+
28
35
C++
29
36
...
30
37
You can’t perform that action at this time.
0 commit comments