high precision in fxscript (was: What problems do you run into when writing plug-ins?)
high precision in fxscript (was: What problems do you run into when writing plug-ins?)
- Subject: high precision in fxscript (was: What problems do you run into when writing plug-ins?)
- From: Mattias Sandstrom <email@hidden>
- Date: Wed, 20 Oct 2010 00:50:58 +0200
oh, and since i give away my plugins for free, here's the source if
someone can figure out how to fix it. the problem is that the 128 offset
is hard coded for 8 bit images so high precision just shifts the whole
image a bit up and left instead of warping the edges (the "edges of the
edges" map is not centered on gray but almost black), but i know of no
way to tell what the offset should be, in the script or manually, not
even hardcoding it to 512 (10-bit) or 32768 (16-bit) seems to work.
// Copyright 2010 Mattias Sandström/Too Much Too Soon
// This script is freeware, meaning you may copy and
// distribute it free of charge, as long as it's kept intact,
// including this message. Feel free to use the code as
// inspiration for your own scripts, but don't steal.
// Email me at email@hidden if you have any questions.
// Thank you. Have fun.
filter "Smart Chroma Sharpen";
group "TMTS Video";
InformationFlag("YUVaware")
input dov, "Direction", popup, 2, "Horizontal (4:2:2/4:1:1)", "Both (4:2:0)"
input amount, "Amount", slider, 3, 0, 10;
code
float w,h,k[2][3][3],i;
dimensionsof(dest,w,h);
image buf1[w][h],buf2[w][h],buff[w][h],thesource[w][h];
if GetPixelFormat(src1) != kFormatYUV219;
setpixelformat(thesource, kFormatYUV219)
ConvertImage(src1, thesource, kFormatYUV219)
else
thesource = src1
end if
// edge detect kernels
k[0]={-1,0,1,-2,0,2,-1,0,1};
k[1]={-1,-2,-1,0,0,0,1,2,1};
// start with black
channelfill(buf1,0,0,128,128);
// detect edges in all four directions and add together
for i = 0 to 3
convolve(thesource, buf2, k[i/2], 1, 0);
add(buf2,buf1,buf1,1,knone);
k[i/2] *= -1;
next;
// blur edges to remove noise and increase width
blur(buf1,buff,sqrt(amount),aspectof(dest));
// find the edges of the edges
convolve(buff, buf1, k[0], 1, 128);
convolve(buff, buf2, k[1], 1, 128);
// copy second luma to "green" channel for vertical displace
channelcopy(buf2,buf1,knone,knone,kred,knone);
// warp image towards its edges
displace(src1, dest, buf1, 1, -amount/500, (1-dov)*amount/500, 0,
aspectof(dest));
// restore source luma
channelcopy(thesource,dest,knone,kred,knone,knone);
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden