Sign in to follow this  
Red ochre

Overblur - changes standard Gaussian blur

Recommended Posts

Overblur

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.

overblurredtree.png

overblurdemo2.png

overblurdemo1.png

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: http://www.getpaint.net/redirect/plugins.html
// 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
#endregion
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;
		}
}
}

  • Upvote 1

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