Skip to content

Add support for writing Gaussian forward and inverse transform lookup tables #3159

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

Merged

Conversation

olegul
Copy link
Contributor

@olegul olegul commented Nov 1, 2021

This patch is an attempt to implement the pre-processing parts from Brent Burley's Histogram-Preserving Blending paper. It generates two float array lookup tables - one for transforming each image channel to a Gaussian distribution (the invCDF float array) and one for transforming from the Gaussian distribution back to the image's distribution (the CDF array).

This will let whoever is consuming the image (like a shader) do the blending on Gaussian distributed data and transform the blended result back to the image distribution, preserving details better than a regular blend.

CDF.data());
}

configspec.attribute("CDF_bits", TypeDesc("int"), &bits);
Copy link
Collaborator

Choose a reason for hiding this comment

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

More compactly as

configspec.attribute("CDF_bits", bits);

(If bits is an int, it knows what to do.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, just FYI, for these simple cases there is yet another syntax (which may or may not be to your taste):

configspec["CDF_bits"] = bits;

@olegul olegul force-pushed the histogram_preserving_textures branch from a576b77 to 72b4502 Compare November 17, 2021 18:20
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 now, thanks.

Were you planning at any point to add documentation or any tests? Or did you want me to try to do that after this gets merged?

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.

Looks like a bunch of the CI tests are failing their builds, can you fix?

* fix signed/unsigned compares
* replace min/max with clamp
* reformat some comments to conform to 80 char margin conventions
@lgritz
Copy link
Collaborator

lgritz commented Nov 25, 2021

I took the liberty of pushing fixes for the signed/unsigned comparison warnings, and a few minor formatting fixes.

@lgritz lgritz merged commit 78a67fe into AcademySoftwareFoundation:master Nov 29, 2021
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Nov 29, 2021
@lgritz
Copy link
Collaborator

lgritz commented Nov 29, 2021

@olegul I merged this so that we can do builds this week that include it, but I think it needs a touch-up to actually document it (i.e., amend the comments for make_texture in imagebufalgo.h, where it explains all the controls it responds to). I can do this if you don't have the time. And ideally -- though perhaps on the OSL side -- we should publish a small example shader that shows how to use this information to do the thing it's designed for.

lgritz added a commit that referenced this pull request Nov 30, 2021
Also, fixed the fact that direct calls to make_texture() were not given
proper defaults for the cdfsigma and cdfbits options.

Related to PR #3159
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Nov 30, 2021
…ion#3206)

Also, fixed the fact that direct calls to make_texture() were not given
proper defaults for the cdfsigma and cdfbits options.

Related to PR AcademySoftwareFoundation#3159
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