// Copyright 2007 Matt 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 mattias@beauty.se if you have any questions. // Thank you. Have fun. filter "Noise Reduction"; group "TMTS Stylize"; input threshold, "Threshold", slider, 25, 0, 100 detent 0; input amount, "Amount", slider, 100, 0, 100 detent 0; input method, "Method", popup, 1, "Average", "Blur", "Heavy Blur"; input msk, "Show Edges", checkbox, 0; code float w,h, clipduration, clipoffset; dimensionsof(dest,w,h); image buf1[w][h],buf2[w][h],buff[w][h],thesource[w][h]; float k[4][3][3], i,clut[256]; thesource = src1; k[0]={-1,0,0,1,-1,0,1,1,-1}; k[1]={0,0,-1,0,-1,1,-1,1,1}; k[2]={0,0,0,-1,-1,-1,1,1,1}; k[3]={0,-1,1,0,-1,1,0,-1,1}; channelfill(buff,0,0,0,0); for i = 0 to 3 convolve(thesource, buf2, k[i], 1, 0); add(buf2,buff,buff,1,knone); k[i] *= -1; convolve(thesource, buf2, k[i], 1, 0); add(buf2,buff,buff,1,knone); next; desaturate(buff,buff); blur(buff,buf1,2,aspectof(buf1)); for i = 0 to threshold clut[i] = 1; next; for i = threshold+1 to 255 clut[i] = 0; next; levelmap(buf1, buf2, clut, clut, clut, clut); blur(buf2,buf1,1,aspectof(buf1)); if msk == 1 then dest = buf1; else if method == 1 then k[0] = {1,1,1,1,0,1,1,1,1}; convolve(thesource,buf2,k[0],8,0); else if method == 2 then blur(thesource,buf2,1.5,aspectof(buf2)); else blur(thesource,buf2,3,aspectof(buf2)); end if; channelcopy(buf1,buf2,kred,knone,knone,knone); matte(buf2,thesource,dest,amount/100,kalpha); end if;