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

Color Space management #1170

Merged
merged 15 commits into from
Oct 19, 2022
Merged

Color Space management #1170

merged 15 commits into from
Oct 19, 2022

Conversation

demoulinv
Copy link
Contributor

@demoulinv demoulinv commented May 5, 2022

Description

A new private metadata named "AliceVision:ColorSpace" is now managed.
Read and Write image update to enable image processing in a color space given as a parameter.
imageProcessing executable updated to take advantage of the above possibility.

Features list

  • AliceVision:ColorSpace metadata added to image file when writing. Possible values are in the list srgb, srgb_linear, aces, acescg.
  • Enable image processing in a color space given as a parameter.
  • Implement color space conversion with OCIO at image reading to enable the selection of another color space than linear or sRGB as working color space.
  • Check existence of the OCIO config file and throw an error if not found when needed. 3 environment variables are considered, ALICEVISION_OCIO, OCIO and ALICEVISION_ROOT, see implementation details.
  • Set the working color space as a parameter in the imageProcessing executable.

Implementation remarks

  • Function getColorConfigFilePath() defined for avoiding some code duplication.
  • OCIO Color config file is first searched by using the ALICEVISION_OCIO env var. If it is undefined or points an unexisting file, the standardized OCIO env var is considered. If it is undefined or points an unexisting file, the ALICEVISION_ROOT env var is considered to point the embedded config file. If the ALICEVISION_OCIO or OCIO environment variables are set, they must be set with the path of the OCIO configuration file to be used.
  • Function getImageColorSpace(imagePath) defined.
  • Color space conversion already implemented at image reading. The target color space, previously named outputcolorSpace , field of the imageReadOptions structure is renamed in workingColorSpace.
  • In order to perform the rigth conversion, the image writer check the AliceVision:ColorSpace metadata, set when processing is done, to identify the working color space.
  • For clarification the parameter imageColorSpace of the writeImage methods is renamed outputImageColorSpace.

@demoulinv demoulinv force-pushed the dev/AVColorSpaceMetadata branch 4 times, most recently from 901803d to fd7deef Compare June 1, 2022 19:37
@demoulinv demoulinv force-pushed the dev/AVColorSpaceMetadata branch 2 times, most recently from 7753256 to cb3c321 Compare September 9, 2022 07:29
@fabiencastan fabiencastan added this to the 2.5.0 milestone Sep 9, 2022
@demoulinv demoulinv force-pushed the dev/AVColorSpaceMetadata branch 2 times, most recently from a7a8ace to 6baec4b Compare September 21, 2022 12:26
return configOCIOFilePath;
}

EImageColorSpace getImageColorSpace(const std::string imagePath)
Copy link
Member

Choose a reason for hiding this comment

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

const std::string&

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does not compile anymore on Windows.

@demoulinv demoulinv force-pushed the dev/AVColorSpaceMetadata branch 6 times, most recently from 4889a6b to 6340ede Compare September 30, 2022 18:53
@fabiencastan
Copy link
Member

I don't understand why we have new build errors on windows CI which does not seem to be really related to the PR:

  D:\a\AliceVision\vcpkg\installed\x64-windows-release\include\boost/mpl/aux_/preprocessor/def_params_tail.hpp(23,10): fatal  error C1083: Cannot open include file: 'boost/preprocessor/identity.hpp': No such file or directory (compiling source file D:\a\AliceVision\AliceVision\src\aliceVision\system\Logger.cpp) [D:\a\AliceVision\AliceVision\build\src\aliceVision\system\aliceVision_system.vcxproj]

@p12tic
Copy link
Contributor

p12tic commented Oct 7, 2022

@fabiencastan I think the commit
SRGB_LINEAR becomes LINEAR to be more compliant with the OCIO config should be combined into the parent commit [Add AliceVision Color Space metadata]. The parent commit renames LINEAR to SRGB_LINEAR and the child commit renames the colorspace back.

There are also a couple of left-overs EImageColorSpace::SRGB_LINEAR changes which I think should be fixed. It's interesting why they don't cause compile errors, maybe they are in code that's disabled..

demoulinv and others added 11 commits October 17, 2022 19:45
Add AliceVision:ColorSpace metadata when writing image.
Manage AliceVision:ColorSpace metadata when reading image.

* Renaming

Complete renaming from outputColorSpace to workingColorSpace when using read image.

* OIIO colorConfig object definition and initialization.

OIIO colorConfig object is defined within io.cpp only. It is initialized with the default OCIO color config file that must be located in the directory src/aliceVision/image/share/aliceVision.
A function declared in io.hpp is available to set another OCIO config file if needed.

Search of OCIO config file strategy:
First try with the ALICEVISION_OCIO env variable.
If unsuccessful, second try with the standardized OCIO env variable.
If unsuccessful, third try with ALICEVISION_ROOT env variable to extract the embedded config file.

* image io

Add log trace when OCIO config file found.
Update OCIO config file by removing the possibility to call the OCIO V1 method to identify the color space from the file name. Default color space is still sRGB.
When reading image, avoid searching input image color space if no conversion is needed.
If conversion is needed, check color space validity after getting it from image metadate or image file name.
Move config.ocio file in subdirectory to ease testing.
Set ALICEVISION_ROOT environment variable in some tests related to image.

* Workflow

Add ALICEVISION_ROOT environment variable in continuous integration.

* Working Color Space implementation in imageProcessing

Transmit working color space to write image and convert to output color space if needed.
Working color space is the color space in which the processing is done. Input images are converted in this color space by the readImage method.
First, search AliceVision:ColorSpace metadata in oiio read buf.
If non-existent or invalid search oiio:ColorSpace metadata in read buf.
If still non-existent or invalid use filename to guess the color space by using the oiio::readmetadata function and then the OCIO configuration file if any.
…ion for Windows in the alicevision_add_test cmake function.
…ontinuous integration github yml file.

CMAKE_INSTALL_PREFIX definition is used by the Cmake function "alicevision_add_test" defined in Helpers.cmake to set the env var ALICEVISION_ROOT for the unitary target target RUN_TESTS.
@fabiencastan fabiencastan merged commit d64eee5 into develop Oct 19, 2022
@fabiencastan fabiencastan deleted the dev/AVColorSpaceMetadata branch October 19, 2022 15:17
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.

3 participants