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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th October 2011, 18:35   #1  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
CineStyle(flat picture style) Lut corrected in Avisynth

Cinestyle LUT correction Avisynth script (using Gradation(vdub plugin) for making the amp curve and GiCoCU.dll to import it into Avisynth):
http://download.videohelp.com/tin2ti...ted_script.zip
Unzip the inclosed files, add some video/image to the script and use it on photos/video shot with DSLR cameras using the CineStyle flat picture style.

About CineStyle: http://blog.vincentlaforet.com/2011/...-canon-5dmkii/

The tutorial I followed: http://zech-fstop.blogspot.com/2011/...thout-lut.html
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 16th October 2011, 20:22   #2  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Another solution, preserving dark shades better because of the 16-bit processing:

Code:
Function correct_cinestyle (clip c)
{
	c
	Dither_convert_yuv_to_rgb (matrix="601", output="rgb48y")
	a  = "0.05"
	x1 = "x 32768 - 32768 /"
	x2 = x1 + " 1.5 * " + x1 + " 3 ^ 0.5 * -"
	x3 = x2 + " 1 " + a + " + * " + x2 + " 3 ^ "+ a +" * -"
	Dither_lut16 (x3 + " 32768 * 32768 +", y=3, u=1, v=1)
	Dither_convert_rgb_to_yuv (
	\	SelectEvery (3, 0),
	\	SelectEvery (3, 1),
	\	SelectEvery (3, 2),
	\	matrix="601", lsb=false, mode=6)
}
Curve fitting
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding

Last edited by cretindesalpes; 16th October 2011 at 20:54.
cretindesalpes is offline   Reply With Quote
Old 16th October 2011, 21:06   #3  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
@ cretindesalpes
Very interesting solution! Completely out of my league. Will try it out.

BTW. With your insights does this description of fixing moire make any sense to you?
Quote:
It blurs the chroma channels of the YCbCr signal (YUV219). If you would call this (wrongly) Y’UV, this would mean blurring the UV part of the signal.
Blur the Cr channel somewhat heavier than the Cb channel while trying to avoid a shift to green – so not to disturb the whitepoint too much. There is some math involved that you can read about here: http://en.wikipedia.org/wiki/YCbCr
From:
http://colorbyjorg.wordpress.com/201...free-download/

Do you think it is possible to replicate that process in Avisynth?
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 16th October 2011 at 21:11.
tin3tin is offline   Reply With Quote
Old 16th October 2011, 22:21   #4  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by tin3tin View Post
Do you think it is possible to replicate that process in Avisynth?
From his description, it sounds like:
Code:
RemoveGrain (0, 11, 11)
RemoveGrain (0,  0, 11)
Maybe with different blur radius or strength. Without masking it may cause important discoloration, too. Anyway I don't know how effective it would be to remove this kind of moiré.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 16th October 2011, 23:00   #5  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Theres an image for testing that here:
http://www.komar.org/faq/camera/auto...cus-test-2.gif

I don't see any differences with the removegrain you mentioned.
__________________
DVD slideshow GUI(Freeware).
tin3tin is offline   Reply With Quote
Old 16th October 2011, 23:14   #6  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
Played around with the settings(haven't read the docs yet). This seems to be an improvement on the moire, however there is a colorshift(left=original and right = RemoveGrain):
Quote:
RemoveGrain (0, 11, 11)
RemoveGrain (11, 0, 0)
http://download.videohelp.com/tin2tin/Moire.png
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 16th October 2011 at 23:36.
tin3tin is offline   Reply With Quote
Old 16th October 2011, 23:22   #7  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
Quote:
Originally Posted by tin3tin View Post
I don't see any differences with the removegrain you mentioned.
Indeed, the author explicitly mentioned that it blurs only the chroma. So it won't make any difference on a black and white picture. The filter was designed for real-life scenes and artifacts generated by a specific camera.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 16th October 2011, 23:27   #8  |  Link
tin3tin
Registered User
 
tin3tin's Avatar
 
Join Date: Mar 2005
Posts: 366
The settings I came up with does add blur. Gotta try with some Canon DSLR shots with micro-moire.

Another test image(photo):
http://www.dcresource.com/reviews/ca...w/IMG_0312.JPG

Quote:
RemoveGrain (0, 11, 11)
RemoveGrain (11, 0, 0)
This seems to have a positive effect on the moire - however the image does get more blured.
__________________
DVD slideshow GUI(Freeware).

Last edited by tin3tin; 16th October 2011 at 23:37.
tin3tin is offline   Reply With Quote
Old 17th October 2011, 07:41   #9  |  Link
LaTo
LaTo INV.
 
LaTo's Avatar
 
Join Date: Jun 2007
Location: France
Posts: 701
Quote:
Originally Posted by tin3tin View Post
The settings I came up with does add blur. Gotta try with some Canon DSLR shots with micro-moire.

Another test image(photo):
http://www.dcresource.com/reviews/ca...w/IMG_0312.JPG

Quote:
RemoveGrain (0, 11, 11)
RemoveGrain (11, 0, 0)
This seems to have a positive effect on the moire - however the image does get more blured.
Your RemoveGrain are wrong, you should only process chroma.
So always leave the first number to 0.

Moreover, your call can be replaced by RemoveGrain(11)...
LaTo is offline   Reply With Quote
Old 19th October 2011, 14:11   #10  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
Quote:
Originally Posted by cretindesalpes View Post
Another solution, preserving dark shades better because of the 16-bit processing:

Code:
Function correct_cinestyle (clip c)
{
	c
	Dither_convert_yuv_to_rgb (matrix="601", output="rgb48y")
	a  = "0.05"
	x1 = "x 32768 - 32768 /"
	x2 = x1 + " 1.5 * " + x1 + " 3 ^ 0.5 * -"
	x3 = x2 + " 1 " + a + " + * " + x2 + " 3 ^ "+ a +" * -"
	Dither_lut16 (x3 + " 32768 * 32768 +", y=3, u=1, v=1)
	Dither_convert_rgb_to_yuv (
	\	SelectEvery (3, 0),
	\	SelectEvery (3, 1),
	\	SelectEvery (3, 2),
	\	matrix="601", lsb=false, mode=6)
}
Curve fitting
Although 16bit it still involves a conversion to RGB, could the sGradation approach be used in dither in order to do it YV12 or YUY2?, http://avisynth.org/mediawiki/SGradation

Using those photoshop .amp's and the GiCoCU.dll is all 8bit RGB and therefore not very desirable.
Yellow_ is offline   Reply With Quote
Old 26th October 2011, 18:43   #11  |  Link
sonu patel
Registered User
 
Join Date: Jan 2009
Posts: 22
great one but can u tell me about how to put white blance colour setting .....
sonu patel is offline   Reply With Quote
Old 4th June 2012, 14:31   #12  |  Link
Boulotaur2024
Registered User
 
Join Date: May 2010
Location: France
Posts: 26
Quote:
Originally Posted by Yellow_ View Post
Although 16bit it still involves a conversion to RGB, could the sGradation approach be used in dither in order to do it YV12 or YUY2?, http://avisynth.org/mediawiki/SGradation

Using those photoshop .amp's and the GiCoCU.dll is all 8bit RGB and therefore not very desirable.
This is a valid question I was wondering the same... I guess the SGradation can *only* be applied to RGB, hence the required convertion ?

I just used CretinDesAlpes function and it does wonder indeed but I have no clue about the syntax and reverse polish notation gives me headache... Could you elaborate a little bit more on it CretinDesAlpes, if you have time ?
Boulotaur2024 is offline   Reply With Quote
Old 4th June 2012, 21:43   #13  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 712
It computes the following formulas:
Code:
a  = 0.05
x1 = (x - 32768) / 32768        ; x1 in -1...1
x2 =   1.5   * x1 - 0.5 * x1^3  ; 1st S curve
x3 = (1 + a) * x2 -   a * x2^3  ; 2nd S curve
y  = x3 * 32768 + 32768         ; Back to 0...65535
First formula converts x from 0–65535 range to -1–+1.
Second formula is the main S curve, keeping x2 in the same range as x1.
Third formula is a second S curve, because the first curve was not enough. The formula is actually the same as the main one, but with a smaller curvature coefficient (0.05 instead of 0.5).
Finally, the fourth formula converts the value back to the 16-bit scale.

Given the CineStyle doc and the provided LUT, the curve works on RGB components, however it's not very clear if they are linear or gamma-compressed. I'd say it's most likely the latter. Working on the Y' signal would not give the expected results.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 4th June 2012, 23:50   #14  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
The LUT is almost certainly applied to gamma compressed data in RGB, the NLE having first squeezed the full range luma levels off the Canon DSLR's into 16 - 235 and the RGB conversion based on that, which is the 'correct' approach in NLE land.

However I'm currently using 32 point '16bit' curve with SmoothCurve16 from SmoothAdjust plugin on the luma channel only, it gives results I'm happy with compared to applying curve to all channels in RGB but a mathmatical approach of correct_cinestyle even better. :-)

Thanks for the correct_cinestyle function, that's neat, will now compare against SmoothAdjust luma only approach based on the RGB route above being correct, how far Y only approach is 'off' although its all subjective, Cinestyle is about capturing data efficiently in camera as best that it can be in 8bit not necessarily tgen applying this curve to give a more typical rec709 appearance.

**EDIT**

I see a lot of gaps in the luma waveform at regular intevals (vertical in case of histogram function) showing some scaling is going on. i don't see this when using SmoothCurve16 and the 32 point curve as the name suggests smoothing via interpolating values is going on to help reduce the gaps.

Needed to add tv_range=false to both color space conversions in order to 'keep' full range luma that is in the original camera files but gaps are still there. :-(

SmoothCurve16 Custom offers ability to mathmatically define a curve so is it possible to combine the two to reduce/remove gaps?

**EDIT**

Testing the 32 point SmoothCurve16 's' curve I have with a few cinestyle videos, by applying it to Y Cb & Cr channels and checking the output with ColorYUV(analyze=true) gives me identical results to cinestyle_correct but without the gaps in the luma channel so it would appear convertion to RGB and back is unnecessary.

I'd kind of already concluded that as the Y only curve gave a better desaturated image for grading with but it is great to be able to test against the cinestyle_correct to confirm that.

I'd assumed from comparing with ColorYUV, Cinestyle with same shot conditions just in other flat camera profiles, that the majority of difference between using Cinestyle (log) and a more typical 'flat' picture style (Linear) was really in the greyscale anyway. And if that's the case using SmoothTweak16 on the Cb&Cr before affecting the luma, which is how I'm currently doing it, so the combined effect can be seen in RGB preview ala AVSPmod, gives more color tweak control.

Last edited by Yellow_; 5th June 2012 at 16:28.
Yellow_ is offline   Reply With Quote
Old 20th April 2013, 10:07   #15  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
Just revisiting this thread and having problem with correct_cinestyle function, getting an error about mtlutxy unsupported color space Masktools only supports Planar YUV, Dither avs line 1022.

Simply feeding it a ffmpegsource decompressed h264 file, to my knowledge I have masktools v20a48 being used.
Yellow_ is offline   Reply With Quote
Old 20th April 2013, 10:12   #16  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
Sorry, I'm sorted, I've been swapping machines about recently and the one I'm using had Avisynth 2.6 alpha not 2.5, even though I tried the -26 version of masktools but got the green screen, obviously something else was not right with the plugins loaded.
Yellow_ is offline   Reply With Quote
Reply

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 11:52.


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