ITK  5.4.0
Insight Toolkit
SphinxExamples/src/Core/Common/IsPixelInsideRegion/Code.py
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 # https://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")
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:70
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54