TechnoRobbo

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

15 posts in this topic

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


 


TRsPXSHMenu.png?raw=1


 


 


 


These are actual examples - try it for yourself.


(My Apologies to Hillary Clinton)


 


TRsPXSH.png?raw=1


 


 


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
#endregion
 
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;
        }
    }
}

TRsPixelSharp.zip

Edited by TechnoRobbo
0

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.


 


Foucs.png?raw=1


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.


Blurred.png?raw=1


 


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


equation.PNG?raw=1


done in Microsoft Equation 3.0


 


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

Edited by TechnoRobbo
0

Share this post


Link to post
Share on other sites

BoltBait,

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.

0

Share this post


Link to post
Share on other sites

Please show us some results.  A picture paints 1K words - just like your excellent explanation images.

0

Share this post


Link to post
Share on other sites

EER,

 

I'm not going to post my kids on the internet but I will message them to you.

0

Share this post


Link to post
Share on other sites

How is this different from the built-in Sharpen ?

0

Share this post


Link to post
Share on other sites

RB,

Very different , observe and try

 

GHB%20Example.png?raw=1

 

my apologies to George Senior 

2 words george - LifeStyle Lift

Edited by TechnoRobbo
0

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 plugin..it set to high imo.

Edited by speedingcheetah
0

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 plugin..it 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
0

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.

 

 

Original

 

fujifilm-finepix40i.jpg

 

 

 

TR Sharpened

 

fujifilm-finepix40i-Trd.jpg

 

 

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

0

Share this post


Link to post
Share on other sites

Thank You,
 

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

 I only support and endorse downloading from this board

1

Share this post


Link to post
Share on other sites

v2.0 adds horizontal and deblurring and larger deblurring range - ready for download

0

Share this post


Link to post
Share on other sites

@Dear TechnoRobbo! Thank you so thanks for all plugins. I Wish you and your family A very Happy Christmas. bdzdah9w.gif

0

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