Sign in to follow this  
TechnoRobbo

Line Tracer Plugin

Recommended Posts

A slightly different take on the sketch plugin.
You will find it in the Menu: Effects - > Artistic
 
Version 1.1 uploaded 10:15 PM Wednesday, June 12, 2013 (UTC) - Noise Filter Implemented
 
Line1.png?raw=1
.
 
Line3.png?raw=1
 
The Code:

 

Hidden Content:
// Submenu: Artistic
// Name: Line Tracer
// Title: Line Tracer - v1.0
// Author: TechnoRobbo
// URL: http://www.technorobbo
#region UICode
int Amount1 = 3; // [1,7] Line Width
int Amount2 = 4;// [1,10] Threshold
int Amount3 = 20;// [0,50] Color
#endregion


void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra CP;
    ColorBgra CO;
    ColorBgra CO2;
    ColorBgra H2O;
    int tmp =0;
    int tmp2 =0;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        for (int x = rect.Left; x < rect.Right; x++)
        {
            CP = src[x,y];
            CO = src.GetBilinearSampleClamped(x-Amount1,y-Amount1);  
            CO2 = src.GetBilinearSampleClamped(x-Amount1,y); 
            H2O = src.GetBilinearSampleClamped(x,y-Amount1); 
            HsvColor hsv = HsvColor.FromColor(CP.ToColor());
            HsvColor hsv2 = HsvColor.FromColor(CO.ToColor());
            HsvColor hsv3 = HsvColor.FromColor(CO2.ToColor());
            HsvColor hsv4 = HsvColor.FromColor(H2O.ToColor());
            int H = hsv.Hue ; 
            int S = Amount3 * hsv.Saturation/100 ;
            int V = Math.Abs(hsv.Value-hsv2.Value);
            tmp = Math.Abs(hsv.Value-hsv3.Value);
            tmp2 = Math.Abs(hsv.Value-hsv4.Value);
            if (V < Amount2 && tmp < Amount2 && tmp2 < Amount2){
                V=100;
            } else {
                V=0;
            }
            
            hsv = new HsvColor(H,S,V);


            ColorBgra NP = ColorBgra.FromColor(hsv.ToColor());
            NP.A = CP.A;  


            dst[x,y] = NP;
        }
    }
}
 
 

Line Tracer.zip

Edited by TechnoRobbo
  • Upvote 2

Share this post


Link to post
Share on other sites

Cool. Reminds me of the old school comic books.  Top work TechnoRobbo. B)

Heres one with a frame

after.png

 

Original image

original.png

  • Upvote 1

Share this post


Link to post
Share on other sites

There's a typo in the script. You're setting "tmp" twice in a row. I'm thinking the second one should be "tmp2".

Also, hsv3 and hsv4 are being set from the same color sample?

Hope this helps.

Share this post


Link to post
Share on other sites

Boltbait,

 

Thanks I missed that, thats part of the algorithm is for noise reduction. I'll post the change when I get home.

 

Thanks Again

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