Red ochre Posted March 16, 2012 Posted March 16, 2012 Noisechoice This is a simple plugin to add noise, with a range of choices. It can add noise to a whole layer or just to an object (eg. a text layer), it can also lower the transparency of the added noise where the original object is anti aliased. The types of noise it can generate are: random coloured opaque, random colour from primary color through to secondary color - this will use the primary and secondary selected transparency too. random greys, black through to white, opaque, primary color, transparency from primary color, secondary color, transparency from color, random transparency only. Adding random noise in itself is not that exciting, but it is great starting point for experimenting with other effects eg. splinter blur, motion blur, zoom or point blur. It is in my plugin pack. Red ochre plugin pack Here is a screen shot of the User Interface (UI). This plugin was written using 'codelab' and Boltbait's excellent tutorials. Here is the codelab code. I recommend anyone with a logical nature to read the tutorials, at the very least it will make plugins more understandable! Here is the codelab code. Hidden Content: //* =================================================== */ /* */ /* noisechoice */ /* (c) 2012 Red Ochre */ /* */ /* Description: versatile random noise tool -v3 hopefully no stripes */ /* */ /* ========================================== ======== */ // Name: noisechoice // Author: Red ochre (John Robbins) // Submenu: Noise // URL: http://www.getpaint.net/redirect/plugins.html // Title: Noise choice March 2012 Red Ochre #region UICode int Amount1 = 128; // [0,255] probability (spacing) byte Amount2 = 0; // colour of noise|random coloured opaque|random primary to secondary|random greys, opaque|primary color only|secondary color only|random transparency only double Amount3 = 0; // [0,1] noise colour blend source colour bool Amount4 = true; // [0,1] noise on object only bool Amount5 = true; // [0,1] keep edge translucency (for text) byte Amount6 = 0; // [255] Reseed #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra cp; ColorBgra pC = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra sC = (ColorBgra)EnvironmentParameters.SecondaryColor; double rat = Amount3;// ratios of noise colour to background colour double irat = 1 - rat; double crat;//random ratios of primary to secondary color double icrat; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { cp = src[x,y]; int B = (int)(RandomNumber.Next(256));B = cp.B;//just to call random again int G = (int)(RandomNumber.Next(256));G = cp.G; int R = (int)(RandomNumber.Next(256));R = cp.R; int A = (int)(RandomNumber.Next(256));A = cp.A; for (int z = 0; z < (byte)RandomNumber.Next(10);z++){}// slow down loop if ((byte)RandomNumber.Next(256) > Amount1) { cp = src[x,y];// copy source pixel or replace with noise pixel // as selected in switch block below } else {switch(Amount2) { case 0://random coloured opaque B = (int)((B * rat) + ((byte)RandomNumber.Next(256) * irat)); G = (int)((G * rat) + ((byte)RandomNumber.Next(256) * irat)); R = (int)((R * rat) + ((byte)RandomNumber.Next(256) * irat)); A = 255;// fully opaque break; case 1://random primary color to secondary color, transparency from color crat = (byte)RandomNumber.Next(256)/256.0;// random primary/secondary color ratio icrat = 1 - crat; B = (int)((B * rat) + (((crat * pC. + (icrat * sC.) * irat)); G = (int)((G * rat) + (((crat * pC.G) + (icrat * sC.G)) * irat)); R = (int)((R * rat) + (((crat * pC.R) + (icrat * sC.R)) * irat)); A = (int)((A * rat) + (((crat * pC.A) + (icrat * sC.A)) * irat)); break; case 2://random black to white opaque int Tv = (byte)RandomNumber.Next(256);// tone value B = (int)((B * rat) + (Tv * irat)); G = (int)((G * rat) + (Tv * irat)); R = (int)((R * rat) + (Tv * irat)); A = 255; break; case 3://primary color, transparency from color crat = (byte)RandomNumber.Next(256)/256.0;// random primary/secondary color ratio icrat = 1 - crat; B = (int)((B * rat) + (((crat * pC. + (icrat * pC.) * irat)); G = (int)((G * rat) + (((crat * pC.G) + (icrat * pC.G)) * irat)); R = (int)((R * rat) + (((crat * pC.R) + (icrat * pC.R)) * irat)); A = (int)((A * rat) + (((crat * pC.A) + (icrat * pC.A)) * irat)); break; case 4://secondary color, transparency from color crat = (byte)RandomNumber.Next(256)/256.0;// random primary/secondary color ratio icrat = 1 - crat; B = (int)((B * rat) + (((crat * sC. + (icrat * sC.) * irat)); G = (int)((G * rat) + (((crat * sC.G) + (icrat * sC.G)) * irat)); R = (int)((R * rat) + (((crat * sC.R) + (icrat * sC.R)) * irat)); A = (int)((A * rat) + (((crat * sC.A) + (icrat * sC.A)) * irat)); break; case 5:// random transparency only A = (int)((A * rat) + ((byte)RandomNumber.Next(256) * irat)); break; } if(Amount4 && src[x,y].A == 0){A = 0;}// limit to object only //keep anti-aliased edge pixel transparency value if(Amount4 && Amount5 && src[x,y].A > 0 && src[x,y].A < 255) { if(A < src[x,y].A){A = (int)(A * (src[x,y].A/255.0));}// allow for translucent primary color else{A = src[x,y].A;}// if opaque noise then take antialiased alpha } } // re assemble cp = ColorBgra.FromBgra( Int32Util.ClampToByte(, Int32Util.ClampToByte(G), Int32Util.ClampToByte(R), Int32Util.ClampToByte(A)); dst[x,y] = cp; } } } 3 Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings
delpart Posted March 16, 2012 Posted March 16, 2012 Noise is an important tool as you mentioned in combination with other things. Like median and some other things it doesn't make a lot of sense at first on why you'd do something so chaotic. The extra range should be nice here. Tanel's Grain plugin is my usual goto for the same reasons of control you have listed here when needing this. Thanks again for widening the toolbox. Quote *** Gallery at PDN-Fans
Red ochre Posted March 16, 2012 Author Posted March 16, 2012 Cheers mate, - I may have to update this one - goonfella and Delpart have reported some problems with the 'primary color' choice - I think I've sussed the problem and will update soon - I've put a 'beta' up to see if it's cured - thing is the problem is really slight on my system but not on Goonfellas judging by the screen shot. Loved the fire & brimstone in your gallery by the way Re toys - I get to play with them first!! - you should see the (terrible) ones I haven't published - I'm still a 'pleb' - well I went to a comprehensive anyway! Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings
AhmedElyamani Posted March 17, 2012 Posted March 17, 2012 I love this plugin! and i began to respect you very much , Red ochre , keep up the good work. Ahmed. 1 Quote
Red ochre Posted March 17, 2012 Author Posted March 17, 2012 Thanks Judith and Ahmed - hopefully I will be improving this one soon Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings
Red ochre Posted March 17, 2012 Author Posted March 17, 2012 I've updated this one - hopefully it won't produce the unwanted vertical lines on the 'primary color' option now - if it does please let me know. I've shown the updated C# codelab code too, if you're curious - not the prettiest code. Sorry for any inconvenience and thanks to Delpart and Goonfella Just about to update the pack now too. Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.