Skip to content

Commit

Permalink
Update Python WSI tutorial documentation (#206)
Browse files Browse the repository at this point in the history
Documentation: Show how to save files from PatchGenerator with the same file name format as ImagePyramidPatchExporter
  • Loading branch information
bonheml authored Apr 30, 2024
1 parent bf59245 commit 019a556
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion doc/pages/Python-tutorial-wsi.dox
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,20 @@ patchGenerator = fast.PatchGenerator.create(512, 512, level=2)\
.connect(1, tissueSegmentation)

for i, patch in enumerate(fast.DataStream(patchGenerator)):
fast.ImageExporter.create(f'patch_{i}.jpg')\
patch_name = f"patch_{i}.jpg"

# Alternatively, if you want to keep track of the tile position and size, it is possible to emulate the filenames produced
# by ImagePyramidPatchExporter as follows:
# level = int(patch.getFrameData("patch-level"))
# x_spacing, y_spacing = int(patch.getFrameData("patch-spacing-x")), int(patch.getFrameData("patch-spacing-y"))
# total_width, total_height = int(patch.getFrameData("original-width")), int(patch.getFrameData("original-height"))
# patch_width, patch_height = int(patch.getFrameData("patch-width")), int(patch.getFrameData("patch-height"))
# patch_overlap_x, patch_overlap_y = int(patch.getFrameData("patch-overlap-x")), int(patch.getFrameData("patch-overlap-y"))
# x_pos = int(patch.getFrameData("patchid-x")) * (patch_width - patch_overlap_x * 2) + patch_overlap_x
# y_pos = int(patch.getFrameData("patchid-y")) * (patch_height - patch_overlap_y * 2) + patch_overlap_y
# patch_name = f"patch_{total_width}_{total_height}_{level}_{x_pos}_{y_pos}_{x_spacing}_{y_spacing}.jpg"

fast.ImageExporter.create(patch_name)\
.connect(patch)\
.run()
@endcode
Expand Down

0 comments on commit 019a556

Please sign in to comment.