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
77Synopsis
88--------
99
10-
1110Create a itk::Size, which represents the size of a region in an itk::Image.
1211
13-
1412Results
1513-------
1614
1715Output::
16+
1817 [0, 0]
1918 [1, 2]
2019
Original file line number Diff line number Diff line change @@ -13,11 +13,17 @@ install( TARGETS IsPixelInsideRegion
1313 COMPONENT Runtime
1414)
1515
16- install ( FILES Code.cxx CMakeLists.txt
16+ install ( FILES Code.cxx Code.py CMakeLists.txt
1717 DESTINATION share/ITKExamples/Code/Core/Common/IsPixelInsideRegion
1818 COMPONENT Code
1919)
2020
2121enable_testing ()
2222add_test ( NAME IsPixelInsideRegionTest
2323 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::
2525Code
2626----
2727
28+ Python
29+ ......
30+
31+ .. literalinclude :: Code.py
32+ :language: python
33+ :lines: 1, 16-
34+
2835C++
2936...
3037
You can’t perform that action at this time.
0 commit comments