Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th August 2021, 06:35   #1  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
ICCConvert - Little CMS based color management in VS

https://github.com/YomikoR/VapourSynth-ICCConvert

I ported some elementary features of Little CMS for color management in VapourSynth.


Features:

- Color profile conversion.
- Playback like in the mpv player (BT.1886 or overridden with a custom gamma).
- Extract color profile from image (when built with ImageMagick 7).
- Auto detection of the display color profile loaded for the current monitor, so that the plugin can be included in a Python wrapper for other users.


About auto profile detection:

- Since the main purpose of the plugin is QC, it's strongly recommended to manually specify the input for actual encoding.
- The detected window refers to the editor interface of VS Editor, or the console where you launch VS Preview, etc., NOT the preview windows of these editors.
- Windows: foreground window.
- Linux, X11: window of input focus. Recommended to build with colord support.
- Linux, Wayland: not yet implemented. Let's see if there will be a colord alternative for Wayland.
- MacOS: not yet implemented. Help wanted.


Help wanted:
- Correctness and auto profile detection in MacOS. I don't have a device.

Last edited by Yomiko; 2nd September 2021 at 10:36.
Yomiko is offline   Reply With Quote
Old 1st September 2021, 10:56   #2  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Release 3.0

- Old function names are changed to "Convert" and "Playback", respectively.
- Added an "Extract" function that provides the embedded ICC profile of an input image with its default rendering intent.
Yomiko is offline   Reply With Quote
Old 19th September 2021, 16:37   #3  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Release 3.2

It has been a lot saner.

Now it can read embedded ICC profiles from the frame property "ICCProfile". Check the flag "prefer_props". These profiles are hashed so that duplication of them from frames won't cause a big performance loss.

This feature is only shipped with the new VS API.
Yomiko is offline   Reply With Quote
Old 19th September 2021, 18:06   #4  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Unfortunately new imwri builds are taking a bit longer than expected due to imagemagick being horrible to compile/link with in windows. Will hopefully be fixed soon.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 17th December 2021, 07:23   #5  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Test with a TIFF image scanned in 48 bit depth and with a "wide gamut RGB" ICC profile embedded, worked. Though the "gamut_warning" seems to not work? I have a sRGB monitor and some of the color on my image is definitely out of sRGB range, but with gamut_warning=True I did not see any indication on my image.

Code:
clip = core.imwri.Read(img, embed_icc=True)
clip = core.iccc.Convert(clip, gamut_warning=True)
clip.set_output()
lansing is offline   Reply With Quote
Old 17th December 2021, 10:08   #6  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Quote:
Originally Posted by lansing View Post
Test with a TIFF image scanned in 48 bit depth and with a "wide gamut RGB" ICC profile embedded, worked. Though the "gamut_warning" seems to not work? I have a sRGB monitor and some of the color on my image is definitely out of sRGB range, but with gamut_warning=True I did not see any indication on my image.

Code:
clip = core.imwri.Read(img, embed_icc=True)
clip = core.iccc.Convert(clip, gamut_warning=True)
clip.set_output()
When my mind was broken I implemented the proofing transform for Convert. The proofing transform takes a backward step, which is required by the gamut warning. Now with the straight transform the flag is ignored.

I may correctly implement the proofing function in the future.

Last edited by Yomiko; 17th December 2021 at 11:26.
Yomiko is offline   Reply With Quote
Old 17th December 2021, 17:54   #7  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Release 4.0

Renamed "simulation_icc" to "input_icc".
Implemented soft proofing.
Yomiko is offline   Reply With Quote
Old 17th December 2021, 17:59   #8  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Quote:
Originally Posted by lansing View Post
Test with a TIFF image scanned in 48 bit depth and with a "wide gamut RGB" ICC profile embedded, worked. Though the "gamut_warning" seems to not work? I have a sRGB monitor and some of the color on my image is definitely out of sRGB range, but with gamut_warning=True I did not see any indication on my image.

Code:
clip = core.imwri.Read(img, embed_icc=True)
clip = core.iccc.Convert(clip, gamut_warning=True)
clip.set_output()
Given an image (with its input_icc) and your monitor (with display_icc), now you may set proofing_icc as display_icc (sorry you have to type the path) for the gamut checking.
Yomiko is offline   Reply With Quote
Old 17th December 2021, 18:42   #9  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Yomiko View Post
Given an image (with its input_icc) and your monitor (with display_icc), now you may set proofing_icc as display_icc (sorry you have to type the path) for the gamut checking.
Can you provide an example code to trigger the gamut warning? I'm confused with proofing_icc vs display_icc.

By guessing:
icc path = C:\Windows\System32\spool\drivers\color
input_icc = scanner's calibration icc
display_icc = sRGB icc
proofing_icc = WideGamutRGB icc

Is this correct?
lansing is offline   Reply With Quote
Old 18th December 2021, 02:02   #10  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Quote:
Originally Posted by lansing View Post
Can you provide an example code to trigger the gamut warning? I'm confused with proofing_icc vs display_icc.

By guessing:
icc path = C:\Windows\System32\spool\drivers\color
input_icc = scanner's calibration icc
display_icc = sRGB icc
proofing_icc = WideGamutRGB icc

Is this correct?
input_icc: the (embedded) icc of the clip/image
display_icc: the monitor icc in spool
proofing_icc: for now let's suppose it's the icc of a printer

Soft proofing is for simulating how the image will be printed, while the result is shown on the monitor.

The printer may not reproduce all the colors of the image. This can be identified by the gamut checking.
In such situation, the rendering "intent" handles how colors are printed. The default value comes from the header of input_icc.

The monitor may not reproduce all the colors of the simulated printing result. This is not identified by the gamut checking.
In such situation, the rendering "proofing_intent" handles how the colors are shown on the monitor. The default value comes from the header of proofing_icc.

For your case it might be
input_icc from image,
display_icc from monitor,
proofing_icc from monitor (same as display_icc).

Last edited by Yomiko; 18th December 2021 at 02:26.
Yomiko is offline   Reply With Quote
Old 18th December 2021, 03:39   #11  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Thanks it worked. The warned area matched what I observed from photoshop's colorpicker.

Code:
srgb_icc = r'C:\Windows\System32\spool\drivers\color\sRGB.icc'

clip = core.imwri.Read(img, embed_icc=True)
clip = core.iccc.Convert(clip, proofing_intent="relative", display_icc=srgb_icc, proofing_icc=srgb_icc, gamut_warning=True)
clip.set_output()



What if I want to check if AdobeRGB color space is able to hold all the gamut of my scan instead of sRGB? Do I just change the proofing_icc to adobergb icc?

Last edited by lansing; 18th December 2021 at 03:52.
lansing is offline   Reply With Quote
Old 18th December 2021, 05:09   #12  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Quote:
Originally Posted by lansing View Post
What if I want to check if AdobeRGB color space is able to hold all the gamut of my scan instead of sRGB? Do I just change the proofing_icc to adobergb icc?
Change both display_icc and proofing_icc to adobergb
Yomiko is offline   Reply With Quote
Old 18th December 2021, 06:50   #13  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Yomiko View Post
Change both display_icc and proofing_icc to adobergb
Okay it worked. AdobeRGB was still not wide enough for the painting lol.
lansing is offline   Reply With Quote
Old 20th December 2021, 18:52   #14  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
How do I keep the large gamut from the image in the output clip for future use like when I get a large gamut monitor? Do I set like display_icc=wide_gamut_rgb_icc and then convert the clip to rec2020?
lansing is offline   Reply With Quote
Old 21st December 2021, 00:48   #15  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
There may be visible detail loss if you do so.
Yomiko is offline   Reply With Quote
Old 21st December 2021, 03:20   #16  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Yomiko View Post
There may be visible detail loss if you do so.
How do I do it properly? From what I understand, imwri reads in the image data, but it needs embed_icc to turn on and the CMS filter to map the color correctly in video form. And since the Wide-Gamut-RGB color profile shared about the same gamut width as Rec2020, converting the RGB48 clip to Rec2020 would preserve all the gamut?
lansing is offline   Reply With Quote
Old 21st December 2021, 03:51   #17  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
That's the right steps. But the problem is that the plugin is not sufficiently accurate. You may try converting forth and back and check the difference.
Yomiko is offline   Reply With Quote
Old 30th December 2021, 23:57   #18  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
I have used the wrong rendering intent on my initial scan, and I don't want to rescan my image. Can I use this plugin to modify it in the input_icc and save it back to the image color profile?
lansing is offline   Reply With Quote
Old 31st December 2021, 06:08   #19  |  Link
Yomiko
Registered User
 
Join Date: Aug 2021
Posts: 73
Maybe, if you were using perceptual

Last edited by Yomiko; 31st December 2021 at 08:10. Reason: made a mistake
Yomiko is offline   Reply With Quote
Old 31st December 2021, 06:35   #20  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
I want to change from "perceptual" to "relative".
lansing is offline   Reply With Quote
Reply

Tags
icc, lcms, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.