Jump to content

Sharpening?


Cookies

Recommended Posts

 I was fiddling with codelab today at school trying to create a highpass filter like the one in photoshop, i ended up having the same effect like the one in photoshop with a radius of 1 and mine with a radius of 3, mine turned out to be more smooth and i noticed that it only needed to be sharpened a bit to end up like photoshop's, my problem is i dont know how to sharpen it, i already called a gaussian  blur so i can't run another effect like that as i understand, codelab source is below

#region UICode
 int Amount1 = 10; // [0,100] Radius
#endregion


// Setup for using Invert pixel op
private UnaryPixelOps.Invert invertOp = new UnaryPixelOps.Invert();

// Setup for using Normal blend op
private UserBlendOps.NormalBlendOp normalOp = new UserBlendOps.NormalBlendOp();

void Render(Surface dst, Surface src, Rectangle rect)
{
    // Setup for calling the Gaussian Blur effect
    GaussianBlurEffect blurEffect = new GaussianBlurEffect();
    PropertyCollection blurProps = blurEffect.CreatePropertyCollection();
    PropertyBasedEffectConfigToken BlurParameters = new PropertyBasedEffectConfigToken(blurProps);
    BlurParameters.SetPropertyValue(GaussianBlurEffect.PropertyNames.Radius, Amount1);
    blurEffect.SetRenderInfo(BlurParameters, new RenderArgs(dst), new RenderArgs(src));
    // Call the Gaussian Blur function
    blurEffect.Render(new Rectangle[1] {rect},0,1);

    // Now in the main render loop, the dst canvas has a blurred version of the src canvas
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            ColorBgra CurrentPixel = src[x,y];

            CurrentPixel = invertOp.Apply(CurrentPixel);
            ColorBgra cp = dst[x,y];
            cp.A = Int32Util.ClampToByte(cp.A / 2);
            CurrentPixel = normalOp.Apply(CurrentPixel, cp);
            CurrentPixel = invertOp.Apply(CurrentPixel);
            
            dst[x,y] = CurrentPixel;
        }
    }
}

Tried some different sharpening code i found with google, they didn't work.

Would be nice if i could adjust the sharpness too

CookiesSigPDN2.png
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...