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. Doom9's Forum tone curves
 Register FAQ Calendar Search Today's Posts Mark Forums Read 22nd October 2015, 11:00 #1  |  Link age Registered User   Join Date: Oct 2015 Posts: 54 tone curves A simply smooth curves adjustement script. curves.7z put curves.py in Python/Lib/site-packages. Usage example: Code: ```import vapoursynth as vs import curves core = vs.get_core() clip = yourclip clip=curves.ycurve(clip,[(0,0),(16191,13364),(32768,32768),(49087,51400),(65535,65535)])```   26th October 2015, 13:16 #2  |  Link age Registered User   Join Date: Oct 2015 Posts: 54 Another version of curve,probably better, with spline interpolation(modification of original code in finesharp.py). Added planes to be processed and changed the way to insert control points (as a string). Code: ```import vapoursynth as vs def spline(x, coordinates): def get_matrix(px, py, l): matrix = [] matrix.append([(i == 0) * 1.0 for i in range(l + 1)]) for i in range(1, l - 1): p = [0 for t in range(l + 1)] p[i - 1] = px[i] - px[i - 1] p[i] = 2 * (px[i + 1] - px[i - 1]) p[i + 1] = px[i + 1] - px[i] p[l] = 6 * (((py[i + 1] - py[i]) / p[i + 1]) - (py[i] - py[i - 1]) / p[i - 1]) matrix.append(p) matrix.append([(i == l - 1) * 1.0 for i in range(l + 1)]) return matrix def equation(matrix, dim): for i in range(dim): num = matrix[i][i] for j in range(dim + 1): matrix[i][j] /= num for j in range(dim): if i != j: a = matrix[j][i] for k in range(i, dim + 1): matrix[j][k] -= a * matrix[i][k] if coordinates=="" : s=x return s else : coordinates=coordinates.replace('-',',').split(",") coordinates = [int(i) for i in coordinates] length = (len(coordinates))//2 i=0 px =[] py =[] while i < ((len(coordinates)-1)) : px.append(coordinates[i]) py.append(coordinates[i+1]) i=i+2 if (length == 1) : s=x return s elif (length == 2) : i=0 x1=px[i] y1=py[i] x2=px[i+1] y2=py[i+1] s= ((x-x1)*(y2-y1)/(x2-x1))+y1 return s else : matrix = get_matrix(px, py, length) equation(matrix, length) for i in range(length + 1): if x >= px[i] and x <= px[i + 1]: break j = i + 1 h = px[j] - px[i] s = matrix[j][length] * (x - px[i]) ** 3 s -= matrix[i][length] * (x - px[j]) ** 3 s /= 6 * h s += (py[j] / h - h * matrix[j][length] / 6) * (x - px[i]) s -= (py[i] / h - h * matrix[i][length] / 6) * (x - px[j]) return s def curve(c, coordinates="",planes=[] ) : core = vs.get_core() lutcurve = [] h=2**c.format.bits_per_sample for x in range(h): x=spline(x,coordinates) x=int(round(x)) if (x <= 0) : x=0 elif (x >= h) : x=h-1 else : x=x lutcurve.append(x) if (len(planes)>0): c= core.std.Lut(clip=c,planes=planes, lut=lutcurve) else: c= core.std.Lut(clip=c, lut=lutcurve) return c # save this file as curve.py # usage: # import curve # clip = curve.curve(clip, "0-0,128-128,255-255", planes=[0,1,2])```  Tags curves Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding     VP9 and AV1 (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD & BD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 18:13.

 Doom9.org - Archive - Top