Sign in to follow this  
Followers 0
Red ochre

Overblur - changes standard Gaussian blur

4 posts in this topic


Now in my plugin pack here:

Red ochre plugin pack

This is a very simple plugin. It compares the blurred picture to the original and lets you choose how much of that change to apply.

Results range from an odd effect useful for making textures through to a passable sharpen effect.




And here is the codelab code:

Hidden Content:

/* =================================================== */
/* overblur */
/* (c) 2012 Red Ochre  */
/* Description: compare blur to source & alter the change */
/* ========================================== ======== */
// Name: Overblur
// Author: Red Ochre (John Robbins)
// Submenu: Blurs
// URL:
// Title: Overblur		  Red ochre		  April 2012
#region UICode
int Amount1 = 10; // [0,50] blur radius
double Amount2 = 0; // [-10,10] overblur		(0 = straight blur,1 = unchanged)	   sharpen(under blur)
bool Amount3 = true; // [0,1] retain original transparency
void Render(Surface dst, Surface src, Rectangle rect)
{ // Call the Gaussian Blur effect
GaussianBlurEffect blurEffect = new GaussianBlurEffect();
PropertyCollection bProps = blurEffect.CreatePropertyCollection();
PropertyBasedEffectConfigToken bParameters = new PropertyBasedEffectConfigToken(bProps);
bParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1);
blurEffect.SetRenderInfo(bParameters, new RenderArgs(dst), new RenderArgs(src));
blurEffect.Render(new Rectangle[1] {rect},0,1);

ColorBgra CP;//current pixel
int cB,cG,cR,cA;// current BGRA values
ColorBgra bP;// blurred destination pixel
int bB,bG,bR,bA;// blur BGRA values
ColorBgra sP;// source pixel
int sB,sG,sR,sA;// source BGRA values
int diffB,diffG,diffR,diffA;
double rat = Amount2 - 1 ;
for (int y = rect.Top; y < rect.Bottom; y++)
	for (int x = rect.Left; x < rect.Right; x++)
		bP = dst[x,y];bB = bP.B;bG = bP.G;bR = bP.R;bA = bP.A;//blur dst values
		sP = src[x,y];sB = sP.B;sG = sP.G;sR = sP.R;sA = sP.A;// source values
		diffB = sB - bB;diffG = sG - bG;diffR = sR - bR;diffA = sA - bA;// difference between them
		cB = sB;cG = sG;cR = sR;cA = sA;// assign current to source

		// simple over blur
		cB = (int)(sB + (rat * diffB));
		cG = (int)(sG + (rat * diffG));
		cR = (int)(sR + (rat * diffR));
		cA = sA;// retain transparency
		if(!Amount3){cA = (int)(sA + (rat * diffA));}

		// re assemble
  CP = ColorBgra.FromBgra( Int32Util.ClampToByte(cB), Int32Util.ClampToByte(cG), Int32Util.ClampToByte(cR), Int32Util.ClampToByte(cA));
  dst[x,y] = CP;


Share this post

Link to post
Share on other sites

I'll try this out later but it looks pretty useful. Thankies!


Share this post

Link to post
Share on other sites

Sweet, looks useful "downloads for later" thanks Red Ochre for the excellent plugins :)


Share this post

Link to post
Share on other sites

Thanks Barbieq25 and Nitenurse79 - hope you're both well and happy :smile:


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0