From 019a556a2763f9c18264cb63f359f47fe5b78207 Mon Sep 17 00:00:00 2001 From: Lisa Bonheme Date: Tue, 30 Apr 2024 11:31:47 +0100 Subject: [PATCH] Update Python WSI tutorial documentation (#206) Documentation: Show how to save files from PatchGenerator with the same file name format as ImagePyramidPatchExporter --- doc/pages/Python-tutorial-wsi.dox | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/pages/Python-tutorial-wsi.dox b/doc/pages/Python-tutorial-wsi.dox index 04e93f8eb..d454bd4ca 100644 --- a/doc/pages/Python-tutorial-wsi.dox +++ b/doc/pages/Python-tutorial-wsi.dox @@ -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