Skip to content

[Fix] Honor channel order for RGB TIFF images - #3337

Open
tandede wants to merge 1 commit into
open-mmlab:mainfrom
tandede:tandede/fix-tifffile-channel-order
Open

[Fix] Honor channel order for RGB TIFF images#3337
tandede wants to merge 1 commit into
open-mmlab:mainfrom
tandede:tandede/fix-tifffile-channel-order

Conversation

@tandede

@tandede tandede commented Aug 19, 2026

Copy link
Copy Markdown

Motivation

Fixes #1101.

The tifffile backend returns standard color TIFF data in native RGB order, but MMCV's documented default is BGR. The backend previously returned the raw array without consulting channel_order, so default reads displayed red and blue channels incorrectly.

Modification

  • Read TIFF metadata to identify images whose photometric interpretation is RGB and locate their sample axis.
  • Reorder the first three samples for BGR output while preserving alpha or other extra samples and supporting both contiguous and planar layouts.
  • Keep non-RGB multi-channel TIFF data unchanged, preserving the backend's remote-sensing use case.
  • Add regression coverage for RGB, RGBA, planar RGB, explicit RGB output, and the existing five-channel non-RGB fixture.

BC-breaking (Optional)

No. This makes the tifffile backend honor the existing channel_order contract. Callers that need native RGB output can continue to pass channel_order='rgb' explicitly.

Validation

  • pytest -q tests/test_image (61 passed)
  • Flake8, isort, YAPF, codespell, and whitespace checks pass for both changed files.
  • No documentation update is needed because this restores the documented channel_order behavior.

@CLAassistant

CLAassistant commented Aug 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tandede
tandede force-pushed the tandede/fix-tifffile-channel-order branch from c2cf607 to fa75633 Compare August 21, 2026 10:50
@tandede
tandede force-pushed the tandede/fix-tifffile-channel-order branch from fa75633 to bc7fff9 Compare August 21, 2026 10:54
@tandede
tandede marked this pull request as ready for review August 21, 2026 11:15
@tandede

tandede commented Aug 30, 2026

Copy link
Copy Markdown
Author

Hi, I checked the current failed statuses. The CircleCI pipeline stops during configuration fetch with “No configuration was found in your project,” while both Read the Docs builds stop during configuration validation because sphinx.configuration is missing. None of these jobs reaches the TIFF implementation or its tests, so they appear to be repository CI configuration issues. Could a maintainer rerun or adjust these checks when convenient? Thanks!

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.

rendering tiff file with wrong colors

2 participants