-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29859a9
commit 60f1ff8
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Filtering/BinaryMathematicalMorphology/ThinImage/Code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import itk | ||
|
||
PixelType = itk.UC | ||
Dimension = 2 | ||
ImageType = itk.Image[PixelType, Dimension] | ||
|
||
if len(sys.argv) == 2: | ||
image = itk.imread(sys.argv[1]) | ||
|
||
else: | ||
# Create an image | ||
start = itk.Index[Dimension]() | ||
start.Fill(0) | ||
|
||
size = itk.Size[Dimension]() | ||
size.Fill(100) | ||
|
||
region = itk.ImageRegion[Dimension]() | ||
region.SetIndex(start) | ||
region.SetSize(size) | ||
|
||
image = ImageType.New(Regions=region) | ||
image.Allocate() | ||
image.FillBuffer(0) | ||
|
||
# Draw a 5 pixel wide line | ||
image[50:55, 20:80] = 255 | ||
|
||
# Write Image | ||
itk.imwrite(image, "input.png") | ||
|
||
image = itk.binary_thinning_image_filter(image) | ||
|
||
# Rescale the image so that it can be seen (the output is 0 and 1, we want 0 and 255) | ||
image = itk.rescale_intensity_image_filter(image, output_minimum=0, output_maximum=255) | ||
|
||
# Write Image | ||
itk.imwrite(image, "outputPython.png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters