Jump to content
How to Install Plugins ×

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


TechnoRobbo

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


 


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
  • Upvote 1

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
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

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 5 months later...

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
Link to comment
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

Go out there and be amazing. Have Fun, TR
TRsSig.png?raw=1
Some Pretty Pictures Some Cool Plugins

Link to comment
Share on other sites

  • 7 months later...

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? ;)

Link to comment
Share on other sites

  • 4 months later...

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

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.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...