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

feat: IBA:demosaic add X-Trans demosaicing #4579

Merged

Conversation

antond-weta
Copy link
Contributor

Description

Implements X-Trans pattern demosaicing using a simple bilinear algorithm. Adds the Xtrans pattern layout to the ImageBuf attributes in the raw reader plugin.

Tests

I have implemented unittests in imagebufalgo_test.cpp which cover all permutations of the Bayer and X-Trans layouts, as the X-Trans pattern is a bit too complicated to generate using oiiotool.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

@antond-weta antond-weta marked this pull request as draft January 1, 2025 01:37
@antond-weta antond-weta force-pushed the iba_demosaic_xtrans branch 7 times, most recently from 7748ff7 to 694a124 Compare January 3, 2025 05:43
@antond-weta antond-weta marked this pull request as ready for review January 4, 2025 06:01
Comment on lines +2179 to +2182
/// The following algorithms are supported for X-Trans-pattern images:
/// - `linear` - simple linear demosaicing. Fast, but can produce artefacts along sharp edges.
///
/// - "layout" : string (default: "RGGB" for Bayer, "GRBGBR BGGRGG RGGBGG GBRGRB RGGBGG BGGRGG" for X-Trans)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure the text alignment is correct here. Can you double check this whole surrounding area? Also might be good to look at the artifacts saved by the "docs CI" to be sure that the resulting documentation definitely look as you imagine it should.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I had checked the artefacts, those looked fine.
I think I've spent a few hours fixing that bit, as I can't build the docs locally. The reason that alignment looks weird is because there are nested bullet point lists, and the 'linear' thingy is a single entry list (made it that way to be consistent with other things) belonging to the previous parameter ('algorithm').

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, thanks, I was just making sure since it was a 2-level list and I wasn't sure from looking these diffs whether everything was aligned as you intended. If they looked ok when viewing the artifacts, then all is fine.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM pending two very minor comments

for (size_t y = 0; y < pattern_size; y++) {
for (size_t x = 0; x < pattern_size; x++) {
int c = channel_at_offset(x + x_offset, y + y_offset);
assert(c < 4);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use OIIO_ASSERT (or OIIO_DASSERT if you are sure you want it to do nothing at all for non-debug builds).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@antond-weta
Copy link
Contributor Author

Larry, with the added unit tests covering all permutations, would it be worth simplifying the oiiotool-based tests to only check that every parameter gets passed to the algo?

@lgritz
Copy link
Collaborator

lgritz commented Jan 13, 2025

Larry, with the added unit tests covering all permutations, would it be worth simplifying the oiiotool-based tests to only check that every parameter gets passed to the algo?

I guess it's not critical to test it all twice. Either way is fine, I guess -- either have thorough C++ unit tests and a perfunctory oiiotool-based test to ensure that the params are all passed, OR if the oiiotool tests can exercise all corners of the algorithm, then the pure C++ tests are actually redundant. Whichever you think is better is fine with me.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM

@lgritz
Copy link
Collaborator

lgritz commented Jan 14, 2025

N.B.: The Windows CI failure is unrelated to this patch and has already been fixed in main.

@lgritz lgritz merged commit dc409d8 into AcademySoftwareFoundation:main Jan 14, 2025
27 of 28 checks passed
@lgritz lgritz changed the title [feat]IBA:demosaic add X-Trans demosaicing feat: IBA:demosaic add X-Trans demosaicing Jan 14, 2025
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jan 14, 2025
…#4579)

Implements X-Trans pattern demosaicing using a simple bilinear
algorithm. Adds the Xtrans pattern layout to the ImageBuf attributes in
the raw reader plugin.

I have implemented unit tests in imagebufalgo_test.cpp which cover all
permutations of the Bayer and X-Trans layouts, as the X-Trans pattern is
a bit too complicated to generate using oiiotool.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jan 14, 2025
…#4579)

Implements X-Trans pattern demosaicing using a simple bilinear
algorithm. Adds the Xtrans pattern layout to the ImageBuf attributes in
the raw reader plugin.

I have implemented unit tests in imagebufalgo_test.cpp which cover all
permutations of the Bayer and X-Trans layouts, as the X-Trans pattern is
a bit too complicated to generate using oiiotool.

---------

Signed-off-by: Anton Dukhovnikov <[email protected]>
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.

2 participants