UDF BasicsDid you ever wish you had a set of specialized blur, sharpen, or edge detect filters? Have you ever wanted an emboss filter that retains the colors of your original image? Maybe you yearned for a filter that would give you something kinda funky. If so, you should probably take a look at User Defined Filters. Many people find User Defined Filters to be totally baffling, and so they never experiment with this handy feature. Other people experiment without really having any idea how User Defined Filters work, and these folks find that most of their experimental filters do nothing more than turn the whole image black or white. The technical discussion in the PSP documentation is fine for what it is, but most of us would do better with some rules of thumb instead of an equation. That's what this tutorial will give you: several User Defined Filter (UDF) rules of thumb that involve only very simple arithmetic. First, let's examine what you'd see if you selected Image | User Defined Filters and then pressed the New button in the resulting dialog box:
For now, ignore the Division Factor and Bias, and pay attention only to the Filter Matrix. The center cell in the matrix corresponds to the pixel that the filter will affect. The surrounding cells correspond to the pixels surrounding the target pixel. What you'll normally want to do (assuming that the Division Factor is kept at 1 and the Bias at 0) is make sure that the sum of the values in all the cells in the matrix equals 1. This will ensure that the overall brightness of the filtered image is the same as the brightness of the original image. If the sum is less than 1, the filtered image will be darker than the original. If the sum is greater than 1, the filtered image will be brighter. Sometimes you'll want your filter to brighten or darken your images. But keep in mind that if you stray too far from 1, you'll get a filter that turns an image either entirely black or entirely white! So here's our first rule of thumb: Unless otherwise compensated for, keep the matrix sum at 1 to retain the brightness of the original image. And here are two corollaries: To brighten an image, make the matrix sum greater than 1. To see what otherwise compensated for in the first rule of thumb means, let's look at the Sample Blur filter that Jasc includes with PSP:
Notice that here the sum of the matrix is 9: there are nine cells with values of 1, and adding together those nine 1's gives us a sum of 9. This sum is greater than 1 by a factor of 9, and we can compensate for that by making use of the Division Factor. By specifying a Division Factor of 9, we divide the sum of 9 by 9, which gives us a result of 1. (See, I told you the math would be simple!) And 1 is just what we need if we want the brightness of the original image to be maintained in the filtered image. So here's our next rule of thumb: To compensate for a sum that deviates from 1, use a Division Factor equal to that sum to maintain the image brightness of the original image. This will work whether your sum (and corresponding Division Factor) is a positive value or a negative value. Keep in mind, too, that you can also use the Division Factor to help adjust the brightness of your filtered image, by using a value that only partially compensates for the sum's deviation from 1. The Sample Blur filter also shows us how in general to get a blurring filter: For a Blur filter, use a positive center value and surround it with a symmetrical pattern of other positive values. In later tutorials we'll examine how to make sharpen, edge detection, and embossing filters, and how to use Bias. Before ending this tutorial, let's look at just one more example and rule of thumb:
Here we've taken the Sample Blur filter and increased the center value to 5, giving us a sum of 13. We've compensated for the increased sum by specifying a Division Factor of 13. This new Blur filter lessens the effect of the Sample Blur filter, as shown in these examples:
This lessening of a filter's effect is something you can get with any UDF, not just with blurring filters. And it will work whether your center value is positive or negative. Here's the rule of thumb: Lessen the effect of a filter by increasing the value in the center cell; compensate with the appropriate Division Factor to maintain the brightness of the original image. That's far from the last word on UDFs! But this basic tutorial should get you well on your way to discovering how to master and make use of User Defined Filters. Back Copyright ©2000 Lamander |