Skip to content

Add ColorBlending module for multi-image blending support - #161

Open
izkgao wants to merge 98 commits into
devfrom
zhenkai/color_blending
Open

Add ColorBlending module for multi-image blending support#161
izkgao wants to merge 98 commits into
devfrom
zhenkai/color_blending

Conversation

@izkgao

@izkgao izkgao commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #160.

Need frontend PR #2759 to be merged first. (merged)

This PR adds color blending support and refactors the session/image APIs around a shared "image-view item" model so frame-backed images and color blendings can be handled consistently.

What is implemented

  • Add a new ColorBlending API with Layer objects for:
    • listing, adding, replacing, deleting, and reordering layers
    • preserving per-layer alpha during reordering/subsetting
    • setting layer alpha and colormaps
    • toggling raster/contour/vector visibility
  • Introduce ImageBase as the shared abstraction for image-view items and move common behaviors such as make_active() and image_view_order onto the base class
  • Update Image to align with the image-view-item model:
    • use file_id terminology consistently
    • expose richer __repr__ output
    • share activation and image-list-order behavior through ImageBase
  • Extend Session with heterogeneous image-view-item support:
    • image_list() now returns both Image and ColorBlending
    • add _find_image_view_order()
    • replace the old image lookup helper with keyword-only image_by_id(image_view_order=..., file_id=..., color_blending_id=...)
    • replace active_frame() with active_image()
    • add create_color_blending() and open_as_color_blending()
    • add cached carta_version and include it in Session.__repr__ when available
    • update set_cursor() to use a better API
  • Add new constants for ImageType and ColormapSet
  • Update documentation and quickstart examples to cover:
    • heterogeneous image lists
    • image-view order
    • color blending workflows

Checklist

  • Add code examples in documentation
  • Add tests

izkgao added 30 commits April 30, 2025 16:38
…or coordinate system and number format methods
…ces for consistency with documentation style
Comment thread carta/color_blending.py Outdated
Comment thread carta/color_blending.py Outdated
Comment thread carta/color_blending.py Outdated
Comment thread carta/color_blending.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/wcs_overlay.py Outdated
Comment thread docs/source/quickstart.rst
izkgao added 13 commits August 12, 2026 09:34
…ge_class registry method for dynamic image-view wrapper instantiation
…or blending alert when making image spatial reference
…le base layer deletion by promoting next layer or closing color blending
… handle base layer by making it the spatial reference
…ding spec.kwonlyargs in parameter name extraction
…et_layer_image, and Session.image_by_id methods with corresponding test coverage

@confluence confluence left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with these changes; I have a few more minor suggestions and a question.

Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/color_blending.py
Comment thread carta/image_base.py Outdated
izkgao added 5 commits August 13, 2026 19:31
…lending classes instead of using ImageBase.image_class factory method
…out codebase, refactor ImageBase to View class, and update related documentation and method names for consistency
…ds parameter to layers method for selective layer retrieval with validation
…images and include corresponding test coverage
…ow explicit image selection and layer ordering, with validation for duplicates and session membership
@izkgao
izkgao requested a review from confluence August 13, 2026 15:01

@confluence confluence left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more issue with fetching lists -- this is the last thing; everything else looks good!

Comment thread carta/session.py Outdated
izkgao added 2 commits August 14, 2026 16:00
…ntend state queries, add validation for out-of-range and closed view indices, and improve error handling for unsupported view types
@izkgao
izkgao requested a review from confluence August 14, 2026 08:29

@confluence confluence left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more set of comments about the list code.

Also, a general comment about code style: because comprehensions are supposed to be compact, I favour using short iterator variable names rather than the long descriptive names that would be more appropriate in a loop. So e.g. it would be fine to write [i for i in some_list if i > something].

(If you prefer to use long names everywhere because of a linting tool, that's fine.)

Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py Outdated
Comment thread carta/session.py
…rator for missing ID/index detection, simplify list comprehensions, and improve error messages to list all invalid values instead of just the first one

@confluence confluence left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to merge this with @kswang1029's approval. I will review the remaining PRs once they're updated after the merge.

@confluence confluence removed the awaiting code review For pull requests that require code review label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting testing For pull requests that require testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support color blending

3 participants