View Single Post
Old 28th February 2015, 01:46   #11  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Limiter is the gamut filter you are looking for (I think).
[EDIT wrong, see next post]

Also, subtracting Limiter's output from the source shows the out-of-range pixels.
Something like this:

On the right-hand "Diff" image, luma < 16 shows as black, white > 235 shows as white, etc
(note source contrast is exaggerated to show the effect)
Code:
Assert(IsYUV(Last), "YUV source required")

## for demo purposes, exaggerate contrast
#ColorYUV(levels="TV->PC")

return Last.ShowOutOfGamut()

##################################
### Show out-of-gamut pixels. 
##
## @ diff_scale - exaggerate the diff signal (range 1..128, default 32)
##
function ShowOutOfGamut(clip C, int "diff_scale")
{
    diff_scale = Min(Max(1, Default(diff_scale, 32)), 128)

    C ## Last==C
    Diff=Subtract(Last, Limiter())
    \ .ColorYUV(
    \  off_y=2*diff_scale, 
    \  cont_y=f2cuv(diff_scale), 
    \  cont_u=f2cuv(diff_scale), 
    \  cont_v=f2cuv(diff_scale))

    return StackHorizontal(
    \  Last, 
    \  Diff.Subtitle("Diff x "+String(Round(diff_scale)), size=Last.Height/8))
    \ .BilinearResize(Last.Width, Last.Height)
}

## scale "normal" float arguments to suit ColorYUV
function f2cuv(float f) { return Round((f - 1.0) * 256.0) }

Last edited by raffriff42; 17th March 2017 at 23:57. Reason: (fixed image link)
raffriff42 is offline   Reply With Quote