Skip to content

Update SP_smallSample.py#6

Open
totochin1222 wants to merge 1 commit into
VirtualPregnancy:masterfrom
totochin1222:patch-3
Open

Update SP_smallSample.py#6
totochin1222 wants to merge 1 commit into
VirtualPregnancy:masterfrom
totochin1222:patch-3

Conversation

@totochin1222
Copy link
Copy Markdown

This script provides a pipeline for downsizing TIFF images from a dataset and optionally rotating them based on sample naming conventions.

Original functionality:

  • Reads TIFF images from a specified folder.
  • Downsizes images by a given scale factor.
  • Converts color channels if necessary to ensure correct saving.
  • Rotates images based on specific naming patterns (e.g., samples containing certain codes like "H710C" or "H750A").
  • Saves downsized images as PNG in a dedicated 'images' folder.
  • Supports parallel processing with multiple CPU cores to speed up the downsizing process.
  • Tracks which images were rotated by saving a "_rotatedImgs.txt" file.

Key functions:

  • downsize: Main function for downsizing and organizing images, handles CPU parallelization.
  • ds: Performs individual image resizing, rotation, and saving.

Modifications / Current usage:

  • Supports multiple image reading libraries (tifffile and cv2) to handle different image formats.
  • Rotation logic is conditional on sample names and an unrotated flag.
  • Added multiprocessing spawn method to ensure compatibility on macOS.
  • Allows flexible input paths and scaling factors.
  • Robust handling of errors during image reading, resizing, or saving, marking failures explicitly.

This script provides a pipeline for downsizing TIFF images from a dataset and optionally rotating them based on sample naming conventions.

Original functionality:
- Reads TIFF images from a specified folder.
- Downsizes images by a given scale factor.
- Converts color channels if necessary to ensure correct saving.
- Rotates images based on specific naming patterns (e.g., samples containing certain codes like "H710C" or "H750A").
- Saves downsized images as PNG in a dedicated 'images' folder.
- Supports parallel processing with multiple CPU cores to speed up the downsizing process.
- Tracks which images were rotated by saving a "_rotatedImgs.txt" file.

Key functions:
- `downsize`: Main function for downsizing and organizing images, handles CPU parallelization.
- `ds`: Performs individual image resizing, rotation, and saving.

Modifications / Current usage:
- Supports multiple image reading libraries (`tifffile` and `cv2`) to handle different image formats.
- Rotation logic is conditional on sample names and an `unrotated` flag.
- Added multiprocessing `spawn` method to ensure compatibility on macOS.
- Allows flexible input paths and scaling factors.
- Robust handling of errors during image reading, resizing, or saving, marking failures explicitly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant