TR's Pixel Sharpener Plugin v2.0 (Dec 21, 2014)

Recommended Posts

TechnoRobbo's Pixel Sharpener V2.0


This is the real deal.

Use it on that photograph that you thought you messed up.


Menu: Effects-> Photo


v2.0 adds horizontal and deblurring and larger deblurring range






These are actual examples - try it for yourself.

(My Apologies to Hillary Clinton)





The Code

// Submenu: Photo
// Name: TR's Pixel Sharpener
// Title: TR's Pixel Sharpener - v2.0
// Author: TechnoRobbo
// URL: http://www.technorobbo]http://www.technorobbo
#region UICode
double Amount1 = 0.75; // [0,1] Sharpen Amount
int Amount2 = 1; // [1,5] Blur Width
byte Amount3 = 0; // Blur Type|Photo|Horizontal Motion|Vertical Motion
void Render(Surface dst, Surface src, Rectangle rect)
    Rectangle sel = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    Surface proxy = src.Clone();
    double blur = (Amount2 - 1)* 2 + 3;
    double qblur= blur * blur;
    double eblur = Math.Floor(blur /2);
    double sblur = Math.Floor(blur /-2);
    ColorBgra CP;
    double Coeff =Amount1;
    double mult = qblur * Coeff + eblur / Amount2 ;
    for (int y = rect.Top; y < rect.Bottom; y++)
        for (int x = rect.Left; x < rect.Right; x++)
            CP = src[x,y];
            int[] sum = {(int)((double)CP.R * mult ),(int)((double)CP.G * mult ),(int)((double)CP.B * mult) };
            for (int i = (int)sblur; i<=eblur; i++){
                for (int j = (int)sblur; j<=eblur; j++){
                    if (i!=0 & j!=0)
                        float nx = x + j;
                        float ny = y + i;
                        if (Amount3==2) nx = x;
                        if (Amount3==1) ny = y;
                        CP = src.GetBilinearSampleClamped(nx,ny);
                        sum[0] -= (int)((double)CP.R * Coeff);
                        sum[1] -=(int)((double)CP.G * Coeff);
                        sum[2] -= (int)((double)CP.B * Coeff);
            CP.R = Int32Util.ClampToByte(sum[0]);
            CP.G = Int32Util.ClampToByte(sum[1]);
            CP.B = Int32Util.ClampToByte(sum[2]);
            dst[x,y] = CP;

Edited by TechnoRobbo
  • Upvote 1

Share this post

Link to post
Share on other sites

How it Works


When you take a digital photograph the lens focuses the light rays from point of detail on your subject onto a pixel on your camera's image sensor.



did this on Google Sketchup



When the your subject appears out of focus the camera has focused the light from a point of detail in front of or behind the sensor in your camera.



As you can see from the diagram the pixels around the intended pixel are now polluted by the unfocused light.


TR's Pixel Sharpener subtracts the light levels of the adjacent pixels from each pixel then amplify's the level of the pixel back to it's intended brightness.

This effectively removes the light pollution from the image and focus is achieved



Hope that makes sense.


I'm not very good at writing equations but I believe it should look like this


done in Microsoft Equation 3.0


where "a" is the current pixel and the "b" series are the immediately adjacent pixels.

Edited by TechnoRobbo

Share this post

Link to post
Share on other sites


It's not an embosser. It actually removes the adjacent pixels influence.

Try it, I ran a whole bunch of old family pics through it. Blew my mind, and I'm the one who wrote it.

Share this post

Link to post
Share on other sites


Very different , observe and try




my apologies to George Senior 

2 words george - LifeStyle Lift

Edited by TechnoRobbo

Share this post

Link to post
Share on other sites


nevermind...i found the "CodeLab" plugin....(I was trying to use Visaul Studio)....derp..


Just wanted to change the default value of his set to high imo.

It depends on the resolution,but that's why I always publish the source code. Fell free to customize.

Edited by TechnoRobbo

Share this post

Link to post
Share on other sites

Just wanna say thanks for this, I seem to get much better results than the inbuilt sharpen.

Wanted a way to sharpen without going to far and this seems to work great.

Your examples go a little to far for my liking, so below is one of my tests.

It was made by duplicating the original to a new layer, tr sharpen by .25, set blend mode to lighten at 127 opacity, duplicate the sharpened layer again and set to darken 255.









TR Sharpened





PS...Ever thought of moving all your code to Github so its easier to get? ;)

Share this post

Link to post
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.

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.