subtype idKGScriptParserduration?ð framebaseencodingparms inputFormat inputCountpublicbogtitlemore filters atuitype typedefaultstringvaluespudwww.fxscript.org stringamounteffect strengthminmaxA ?€?€rampB´colourcolourÿÿÿÿgraphondraw graph (preview only)privatestaticsscriptb//--------------------------------// // Stib's simple Colouriser // //for more visit www.fxscript.org // //--------------------------------// //copyright2005 stephen dixon //This software is free - you may use, modify and distribute it as you wish, with the following provisos: //*it may not be used by any military organisation, or to produce goods or services for any military organisation. //* this source code must remain open //* this message and the accompanying doccumentation files must remain with the source //additionally this software is released under the terms of the GNU general Public license //see http://www.gnu.org/licenses/gpl.html for the full text of this license or look at the readme that came with the plugins //this software comes with no warranty of fitness for any purpose whatsoever, ok. //see www.fxscript.org for more //if you like it or if you do something creative with it let me know, I'd love to hear from you. //There was a filter called colouriser, that has since become colour engine, //and this is a cut down version of that with simpler controls get it? filter "simple colouriser"; group "stib's filters"; // a simple colourising tool input bog, "more filters at", Label, "string" input spud, "www.fxscript.org", Label, "string" input amount, "effect strength", slider, 1, 0, 10 ramp 90; input colour, "colour", Color, 255, 255, 0, 0 input GraphOn, "draw graph (preview only)", CheckBox, true InformationFlag("YUVaware") //new for version 3.0! code float i, clut_RGB[3][256], colouriseColour[3] float ColourChannel,w, h; dimensionsof(dest, w, h); //get dimensions for our image buffers image YUVRGBBuffer[w][h], buf1[w][h]; //load the slider values into some arrays //munge the colour input {255,255,255,255} into something we can use: {0.5,0.5,0.5}. colouriseColour = {colour.R, colour.G, colour.B} colouriseColour -=128 colouriseColour /=255 // ---------------- set up the CLUTs. ---------------- for ColourChannel = 0 to 2 for i = 0 to 255 clut_RGB[ColourChannel][i] = i*(1+Amount*(colouriseColour[ColourChannel]))/255 ; next; next; //---------------- process the pixels ---------------- if (colouriseColour[0]+colouriseColour[1]+colouriseColour[2]!=0) && (amount != 0) //only do the processing if there is processing to do if (GetPixelFormat(src1) == kFormatYUV219); //oh I'm so clever these days, writing YUV aware plugins and all //----------------convert YUV to RGB if source footage is YUV ---------------- //----------------process as RGB---------------- setPixelFormat(YUVRGBBuffer, kFormatRGB255); ConvertImage(src1, YUVRGBBuffer, GetPixelFormat(src1)); levelmap(YUVRGBBuffer, buf1, LinearRamp, clut_RGB[0], clut_RGB[1], clut_RGB[2]); if (GetPixelFormat(dest) == kFormatYUV219) ConvertImage(buf1, dest, kFormatYUV219); else dest = buf1 //the buffer and dest are in the same colour space so just dump it out end if else //----------------process in the native RGB format without conversion---------------- levelmap(src1, dest, LinearRamp, clut_RGB[0], clut_RGB[1], clut_RGB[2]); end if else dest = src1 end if //--------------------------------------draw graph ------------------------------------------- if GraphOn && previewing{ //only draw the graph in previews, so you don't have to worry about turning it off for final renders float screenwidth, screenheight color lineColour[3]; string labelStr[3]; point Xleft ,Xright , Ytop, RgraphPoint , GgraphPoint , BgraphPoint DimensionsOf(dest, screenwidth, screenheight); screenheight *= 0.8; screenwidth *= 0.8; Xleft = {0-screenwidth/2, screenheight/2} Xright = {screenwidth/2, screenheight/2} Ytop = {screenwidth/2, 0-screenheight/2} Line(Xleft , Xright , dest, kwhite, 2) Line(Xright , Ytop , dest, kwhite, 2) //x & y axes lineColour[0] = {0,255,0,0} lineColour[1] = {0,0,255,0}; lineColour[2] = {0,0,0,255}; labelStr[0] = "r" labelStr[1] = "g" labelStr[2] = "b" for ColourChannel = 0 to 2 for i = 0 to 255 if clut_RGB[ColourChannel][i] > 0 and clut_RGB[ColourChannel][i] < 1 RgraphPoint = {i/256*screenwidth - screenwidth/2,(screenheight/2)-clut_RGB[ColourChannel][i]*screenheight}; DrawSoftDot(Dest, RgraphPoint, kRound, 3, 5, 1, lineColour[ColourChannel], 100, 1) // plot the red graph end if next; DrawString(labelStr[ColourChannel], RgraphPoint.X, RgraphPoint.Y, 10, dest, lineColour[ColourChannel], 1) next; end if; namesimple colouriserscriptid-groupstib's filtersYUVawareencoded