Sign in to follow this  
Followers 0
ownage

Toon Filter

58 posts in this topic

afterwf0.jpgafterwm6.jpg

Compiled DLL

TOON.zip

Just unzip this file and save the dll file in your /Program Files/Paint.NET/Effects folder.

Code Lab Code

// filter kernel

const int size = 5; // odd number


//play around with the matrix for interesting effects.

int[,] conv = new int[size, size] {
		                       {-1,  -1,  -1,  -1, -1},
		                       {-1,  -1,  -1,  -1, -1},
		                       {-1,  -1,  30,  -1, -1},
		                       {-1,  -1,  -1,  -1, -1},
		                       {-1,  -1,  -5,  -1, -1},
   				              };

unsafe void Render(Surface dst, Surface src, Rectangle rect)
{	
   int radius = (size-1)/2;
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       int top = y - radius, bottom = y + radius;
       if (top < 0) top = 0;
       if (bottom >= dst.Height) bottom = dst.Height - 1;
       for (int x = rect.Left; x < rect.Right; x++)
       {
           int left = x - radius, right = x + radius;
           int c = 0, s = 0, r = 0, g = 0, b = 0;
           if (left < 0) left = 0;
           if (right >= dst.Width) right = dst.Width - 1;
           for (int v = top; v <= bottom; v++)
           {
               ColorBgra *pRow = src.GetRowAddressUnchecked(v);
               int j = v - y + radius;

               for (int u = left; u <= right; u++)
               {
                   int i = u - x + radius;
                   int w = conv[i, j];
                   ColorBgra *pRef = pRow + u;
                   r += pRef->R * w;
                   g += pRef->G * w;
                   b += pRef->B * w;
                   s += w;
                   c++;
               }
           }
           dst[x, y] = ColorBgra.FromBgr(
               Utility.ClampToByte(b),
               Utility.ClampToByte(g),
               Utility.ClampToByte(r));
       }
   }
}
 
0

Share this post


Link to post
Share on other sites

I seem to get a different effect when I apply the filter to the picture at the top, are you going to add a way to adjust the level of the filter?

You can get a good effect if you take a picture, duplicate the layer, apply the filter to the top level and play with the opacity.

0

Share this post


Link to post
Share on other sites

you can get a pencil sketch kind of effect.

alita02fi3.jpgalita02toonvm4.jpg

intensity of the filter is controlled by the size of the filter kernel matrix, bigger matrix = higher intensity.

0

Share this post


Link to post
Share on other sites

Cool plugin, might have to look at adding something like this for a 2.7x update ;)

Is that Rachel Bielson? I can think of only positive things to say about her ... ha!

0

Share this post


Link to post
Share on other sites
Is that Rachel Bielson? I can think of only positive things to say about her ... ha!

LOL!

0

Share this post


Link to post
Share on other sites

I love your Toon filter, but it needs an icon in the effects menu.

Oh, and I've noticed that the TOON filter interacts nicely with other filters. For example, taking your original image I did a Frosted Glass (1), TOON, Blur (1):

afterwf0.jpgFG1_TOON_GB1.jpg

This gives is a very rough look (crayons?) that I really like.

I think a lot can be learned by looking at the source code to this effect.

0

Share this post


Link to post
Share on other sites

I go for more of a ditigalized look I guess if you can call it that.

I gotta get on my fast comp to do this though.

Take a pic, TOON it, then blur it 1-2 px

0

Share this post


Link to post
Share on other sites

Link for download give an error page (with a lot of virus inside, as my antivirus said)... there is not a direct link for this?!?

0

Share this post


Link to post
Share on other sites

:D

Thanks for the reposting. It works great. Remember to place it in your ../effects directory.

0

Share this post


Link to post
Share on other sites

wow...it works great! I wonder if they could make a plug-in to do the opposite...

0

Share this post


Link to post
Share on other sites

Is there any way to actually adjust anything in this plugin?

All i can do is "Tool", and then my img gets changed, but after two times "Tool" there is nothing new anymore...

0

Share this post


Link to post
Share on other sites

@ ownage

it'S a really good PlugIn, but how did you do pics like your first?

I can't!?

It don't looks like your's...

0

Share this post


Link to post
Share on other sites

Discovered one way to improve the results for some pictures:

1. Apply the toon effect to the background pic

2. Copy the toon effect to the clipboard

3. Undo the toon effect on the background to get its original state

4. Create a new layer, paste the clipboard contents, and then going to the Layer --> Layers Property, adjust the opacity to about 139 or whatever setting suits your eye.

5. Flatten the immage.

I think these steps create quite lovely pictures.

0

Share this post


Link to post
Share on other sites

davidtayhs, that sounds similar to what I described in this post:

http://paintdotnet.12.forumer.com/viewtopic.php?t=2785

(scroll down about half way and you'll see this picture...)

2kids.jpg

Here is how to make this picture:

Before you begin, you'll need the Toon effect plugin and optionally the Pastel effect plugin.

Open an image. It opens on the background layer.

Duplicate the background layer. Call this layer "outline". Make it invisible for now.

Select the backgound layer and run the Oil Paint effect (defaults).

Now Gaussian Blur the background layer with Radius 1.

Select the background layer and run the Glow effect. Radius 6, lower the contrast, adjust the brightness as desired. I used -78 on both for this picture.

(Or, you could just run the crappy Pastel effect I wrote.)

Select the "outline" layer and make it visible.

Run the Toon effect on the outline layer.

Now select Adjustments > Black and White.

Create a new layer called "Eyes".

Select the "outline" layer and lasso the whites of the eyes. You'll have to do these one at a time. Copy the white area of the eyes and paste it into the new "Eyes" layer.

When done with that, select the "Eyes" layer and Gaussian Blur it with a Radius 1.

Select the "Outline" layer and change the properties to Blending Mode: Darken.

That's it. ;)

NOTE: You don't have to do all of these steps anymore. I have created an effect that will do them all for you! Download it here:

http://paintdotnet.12.forumer.com/viewtopic.php?t=4085

Enjoy. 8)

0

Share this post


Link to post
Share on other sites

Nope, your technique definitely gives superior results.

Didn't think of combining so many effects together - Oil Paint, Gaussian Blur, Glow, Toon effect etc!

Was experimenting to get a better result from the Toon effect. Liked your result so much I printed out the steps and the photo for reference. Thanks.

0

Share this post


Link to post
Share on other sites
Nope, your technique definitely gives superior results.

Thanks!

I'm always on the lookout for techniques that would take a normal photograph and turn it into something "drawn". To me, this makes it look as if the picture was drawn in pen and painted with water colors.

This technique is the closest I've come using Paint.NET.

BTW, sometimes it looks better to use "Screen" instead of "Darken" in the last step.

0

Share this post


Link to post
Share on other sites

You might try utilizing the "Outline" effect as well (comes with 3.0).

0

Share this post


Link to post
Share on other sites

Rick, I've tried it, but honestly the Toon filter gives MUCH better results.

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
Sign in to follow this  
Followers 0