Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and Optimize Image Loading and Saving Functions #14

Open
GautamAnjali569 opened this issue Jan 28, 2025 · 0 comments
Open

Refactor and Optimize Image Loading and Saving Functions #14

GautamAnjali569 opened this issue Jan 28, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request IWOC2025 Medium

Comments

@GautamAnjali569
Copy link
Member

Overview

This pull request introduces improvements and optimizations to the image loading and saving functions in the code. The main goal is to make the code cleaner, more maintainable, and more efficient.

Changes Made:

  1. Refactored default_image_loader:

    • Ensured that default_image_loader correctly handles the selection of either the jpeg4py_loader or opencv_loader without redundant code.
    • Improved error handling for image loading failures.
  2. Added a failsafe in jpeg4py_loader_w_failsafe:

    • If jpeg4py fails to load an image, the function now reverts to opencv_loader as a fallback.
    • More robust error handling to ensure that an image is always loaded or a clear error message is shown.
  3. Optimized opencv_loader:

    • Streamlined error handling and ensured that OpenCV's image loading is more reliable.
  4. Improved Segmentation Loader (opencv_seg_loader):

    • Refined the opencv_seg_loader to ensure consistent error handling and better messages for segmentation-specific image loading.
  5. Refined imread_indexed and imwrite_indexed:

    • The code now handles indexed image reading and saving more cleanly, ensuring that segmentation annotations are correctly processed and saved in a more user-friendly way.
    • Added the color_palette parameter to imwrite_indexed to allow for custom color palettes for indexed images.
    • Ensured that imwrite_indexed properly handles saving 2D arrays as indexed PNGs with color palettes.

Motivation

These changes help streamline the image processing and loading workflow. By improving the code structure, error handling, and fallback mechanisms, this PR enhances the tool’s reliability and readability, making it more maintainable and easier to extend in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request IWOC2025 Medium
Projects
None yet
Development

No branches or pull requests

2 participants