Announcement

Collapse
No announcement yet.

Free Plug-In Filters: Custom Filter & Adaptive Equalization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Free Plug-In Filters: Custom Filter & Adaptive Equalization

    While looking for info on 'Fovea Pro' (which may be too deep for me) I stumbled over these three plugs - which may be of interest (the third less so for most users):

    Custom Filter: Just as unintuitive as the Adobe one, but with more options (KPT Convolver seems to be the king of convolutions).

    Adaptive Equalization: implements a technique for increasing the local contrast of images by reducing overall dynamic range. It is particularly useful for making small surface marks visible, or revealing detail in shadow areas, while preserving color information.

    http://www.reindeergraphics.com/free.shtml

    Regards,

    Stephen Marsh.

  • #2
    I have had some small time to play with these two filters since posting...

    The Custom Convolution Filter is like Photoshop's filter/other/custom with floating point precision (as if convolution needs to be made harder with more precision than simple integer math) and a few other options including high bit edit ability. The supplied matrix txt files are loaded into the plug to give you a start on using this very unintuitive 'filter maker'.

    The Adaptive Equalization filter is similar in result in some ways to my 'EnhanceDetail' action:

    http://www.retouchpro.com/forums/att...=&postid=20574

    You REALLY do NOT want to use this on skintones (unless going for the reptile look) - but for shadow detail, natural rough detail in rocks, old metal and other 'rough' objects this can add some much needed detail and local contrast, using a duped filtered layer blended at 2-5% (yes, really low) opacity in different blend modes may help (luminosity, multiply, hard light, overlay, experiment!). Shadow detail may use some higher opacity, such as 10% or perhaps higher for the right image/blends, but highlight detail only seems to need a very minor opacity blend (you can use blend if sliders or masks to reduce the effect more so in the highlights than the shadows etc).

    In addition to contrast masking, 'coming out of the shadows' and other shadow lifting tricks, this filter can help bring out shadow detail - but it can also bring out posterized shadows, JPEG artifacts, noise and other junk. Due the local contrast boost, some dark halo USM type effect is also a side benefit of this filter.

    Before using this filter, it might be wise to use methods similar to ones described in a small article of mine (Photoshop 5 action included to help demonstrate the methods in the article):

    http://members.ozemail.com.au/~binar...ctremoval.html

    With further exploration this filter may prove useful for retouching and perhaps extraction, when combined with other methods...

    Take care with this filter, poor application may ruin things just as quick as helping.

    Stephen Marsh.

    Comment


    • #3
      Stephen,
      I downloaded them all and extracted them. I haven't moved the filters to the PS plugin file yet. In one of them there are several folders with text files of numbers in them. Where did you put them? In the plugins folder as well? I skimmed over the PDF file but saw nothing to explain where to put them. Just curious.
      DJ

      Comment


      • #4
        Hi DJ, these are the Custom Convolution filter settings, which are manually loaded from within the third party Custom filter in question (to save you typing in all those numbers).

        I personally store the plug in a folder called Custom Convolution and the folders in question live there (but they could be anywhere on your drive/s).

        It is then a simple matter to navigate to the plug folder to find the files to load. I do the same for Actions, Adobe custom filter kernels, brushes etc...all live in a Goodies folder within the apps folder for easy access.

        I am just about to try to find a demo version of KPT Convolver as I am getting sick of doing maths just to get a result I finally find that I don't like. <g>

        Stephen Marsh.

        Comment


        • #5
          Oh thank God. I was thinking I would have to type in all those numbers myself. Thanks
          DJ

          Comment


          • #6
            Custom (Both Adobe's and Reindeer's versions)

            Do you want me to give you a tutorial on the kinds of things that you can do with a convolution kernel and what they're good for?

            The reason we provide that kind of plug-in is because it is the basis for image processing. You can do bluring, sharpening, edge-detection, pattern matching and a host of other things with kernels, so it seemed natural to provide (albeit unintuitive) this kind of tool.

            -Chris Russ

            Comment


            • #7
              Chris - firstly, welcome and thank you for posting - it is nice to have the plugs creators willing to lend a hand, when it is not really a problem with the plug itself.

              Thanks for the kind offer of a tutorial - yes that would be VERY welcome.

              I understand that convolving is a complex topic and is based in maths and pixel brightness levels, but the simpler the better would be my vote...I have read many tutorials from software makers and math geeks - but for an average GUI based user, this is all very foreign...add in floating point precision - and things just get harder for the newbies like me! <g>

              Stephen Marsh.

              Comment


              • #8
                Convolution
                Let's start with the basics. What you're really doing is creating a new image a pixel at a time, using the rules in the kernel.

                Consider the center of the kernel (5x5 in Photoshop, 7x7 with my Custom plug-in) to be the original pixel, and the squares around it to be its neighbors. If we used a kernel like this:

                0 0 0 0 0
                0 0 0 0 0
                0 0 1 0 0
                0 0 0 0 0
                0 0 0 0 0 (set the scale to 1 offset to 0)

                Add extra zeros around the outside to get to a 7x7:
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 1 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (set the scale to 1 offset to 0, or turn on “Autoscale”)

                This is called the identity function. If you use this kernel you will get out exactly what was put it. The weight on the center pixel is 1.0, and the weights on the neighbors are all 0.0, so the image is left alone.

                Add an Echo

                If we change it to look like this:

                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 1 0 0 1
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (set the scale to 2 offset to 0, or turn on “Autoscale”)

                You add an “echo” that is 3 pixels to the right, and the image seems to shift 1 1/2 pixels to the right (halfway between the center and the echo).

                Embossing

                Let’s change the value to the right to be a –1 instead.

                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 1 0 0 –1
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (set the scale to 1 offset to 128, or turn on “Autoscale”)

                This shows you the difference between the central value (the original image) and the value 3 pixels to the right. We’ve just invented embossing.

                The –1 doesn’t have to be the value 3 pixels to the right. In fact, it could be ANY of the neighbors. Try it.

                The technical name for this is a Directional Derivative – we’re taking the 1-D derivative or the rate of change from a pixel to its neighbor which gives us the slope of the signal. Not really meaningful unless you can think of the brightness of the image as a surface (treat the values as altitudes).

                The derivative tends to be large (either positive or negative) when the image is changing rapidly. This can happen in two places: edges and noise.

                Averaging (or blurring)

                We can get rid of noise by adding neighbors together. Try the following kernel:

                0 0 0 0 0 0 0
                0 0 1 1 1 0 0
                0 1 1 1 1 1 0
                0 1 1 1 1 1 0
                0 1 1 1 1 1 0
                0 0 1 1 1 0 0
                0 0 0 0 0 0 0 (set the scale to 21 offset to 0, or turn on “Autoscale”)

                This is an approximation of a round neighborhood where all 21 values are added together. The original pixel is therefore 1/21 of the result. This is a significant blur.

                Let’s try to blur in only one direction:
                0 0 0 0 0 0 1
                0 0 0 0 0 1 0
                0 0 0 0 1 0 0
                0 0 0 1 0 0 0
                0 0 1 0 0 0 0
                0 1 0 0 0 0 0
                1 0 0 0 0 0 0 (scale 7 offset 0, or turn on “Autoscale”)

                (With Photoshop, use the center 5x5 and set the scale to 5 offset to 0)

                This will be a blur in one direction (45 degrees). You could try thickening the line to see what that does.

                Q: What about scale and offset?

                Here’s a good rule of thumb:
                If the sum of the values is zero (e.g. the embossing case, directional derivatives), then the offset should be 128. The scale works if it is the sum of the positive values in the kernel. You aren’t restricted to that, but it is a good place to start. Or, you can turn on “Autoscale” and our Custom filter will do the work (it will find the largest and smallest value and make sure they fit in the 0..255 range).

                Sharpening

                We’ve seen that you can (sort of) find an edge with a derivative. How does “Trace Edges” work? They use two different kernels and add the results of the images together. (This is a simplified version of a Sobel Edge Detector, named after the guy, but it is similar to Trace Edges.)

                We’ll take some directional derivatives (do each of these in different layers):
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 1 0 -1 0 0
                0 0 1 0 -1 0 0
                0 0 1 0 -1 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (scale = 3 offset = 0, autoscale OFF)

                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 -1 0 1 0 0
                0 0 -1 0 1 0 0
                0 0 -1 0 1 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (scale = 3 offset = 0, autoscale OFF)

                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 -1 -1 -1 0 0
                0 0 0 0 0 0 0
                0 0 1 1 1 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (scale = 3 offset = 0, autoscale OFF)

                0 0 0 0 0 0 0
                0 0 0 0 0 0 0
                0 0 1 1 1 0 0
                0 0 0 0 0 0 0
                0 0 -1 -1 -1 0 0
                0 0 0 0 0 0 0
                0 0 0 0 0 0 0 (scale = 3 offset = 0, autoscale OFF)

                Now use the transfer mode “Lighter” between all of the layers. This gives you the biggest “step up” from each of the 4 directions (there is a way to do 8 directions) as a new image. This is a map of where the edges are. Also note, we’re using a little bit of blur in the other direction when doing the derivative. This helps reduce the effect of noise when “Tracing Edges”.

                That’s enough for today, but next time we’ll talk about Gaussian Blurs, Laplacian (2nd-derivative edge enhancement), high-pass and low-pass filters, and the “Mexican Hat” filter.

                -Chris Russ

                Comment


                • #9
                  Interest in this topic?

                  Questions, problems, things I should know, things I SHOULDN'T know?

                  If you're not interested, then I'll stop.

                  Comment


                  • #10
                    Please don't stop, it's fascinating. Way over my head, but fascinating.
                    Learn by teaching
                    Take responsibility for learning

                    Comment


                    • #11
                      Chris, please keep going. This is great stuff.

                      I worked with convolution for linear data streams for signal processing, but 2D images are a great deal more complex. There are a lot of transforms I have wanted to try, and I know there are many more that are more specific to other kinds of images than the microscopy I used to work with... I will happily read whatever you are willing to type on the subject.

                      --tks

                      Comment


                      • #12
                        Chris, please post on!

                        I have printed out your 'basic' post for extended study and practice. This is deep stuff for a GUI user to get into - so I have not had time to really push things.

                        I will hold back on my current questions, as they may well be covered in your next tutorial...if not I will post away.

                        Here is a link to a great little tutorial which forces you to think and to correctly answer a question before proceeding to the next step - which I think is a novel way to present such a deep topic:

                        http://www.eas.asu.edu/~karam/2dconvolution/

                        Regards,

                        Stephen Marsh.

                        Comment


                        • #13
                          Chris:

                          Yours is the BEST how-to / decriptive writeup on custom filters I've seen anywhere. Most are just a paragraph or two with no depth whatsoever.

                          This is EXCEPTIONAL stuff.

                          Many thanks to you for sharing your expertise.

                          ~~~~~~~
                          And another BIG thumbs up to Stephen for another enlightening thread with valuable content.

                          ~Danny~

                          Comment


                          • #14
                            Convolution, Round 2

                            So, let us recap a little bit. The center of the 5x5 or 7x7 (or whatever size the kernel is) refers to the weight on each pixel in the original image. The positions around that center pixel refer to weights on the neighbors of that pixel. All of this applies when creating a new image from the original.

                            Gaussian Filters

                            Back in the dark old days where computers were slow we had to do a lot of work-arounds to get the operations done in our respective lifetimes. We also worked with 3x3 Kernels because they were easier and a lot faster.

                            So, you would think that the first blur that we developed was the following kernel:

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 1 1 1 0 0
                            0 0 1 1 1 0 0
                            0 0 1 1 1 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 9, offset = 0)

                            But you’d be wrong. This kernel has two problems:
                            1. The sum is 9. Division was a sloooow operation, unless you were dividing by a power of 2. As we saw before, you’d have to use a scale of 9 in order to make this kernel work, so this wasn’t a good choice.
                            2. The kernel is square. More blurring goes on in the diagonals than horizontally and vertically and this is a visible artifact.


                            So, instead we used the following kernel which is nearly a Gaussian:

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 1 2 1 0 0
                            0 0 2 4 2 0 0
                            0 0 1 2 1 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 16, offset = 0)

                            It turns out that dividing by 16 on a computer is really easy and fast, and even more useful, multiplying by a power of 2 is really easy and fast, so this was the first useful blur kernel.

                            Another useful tidbit is that if you reapply several little Gaussians, you get a big Gaussian. Try it.

                            One big problem with kernels is that as they get bigger, they get a lot slower. A 5x5 has 25 multiplications. A 7x7 has 49 multiplications and takes about twice as long. Yet, the difference in the blur between radius=2 and radius=3 really isn’t that much. And if I want a radius=20, this could really take a lot of time.

                            So how does Chris Cox (the optimization guru at Adobe) do it? How does he make the Gaussian blur function so fast? He cheats.

                            First he convolves the image with a horizontal Gaussian Blur (example below is a radius=1.0) and then with a vertical Gaussian Blur. He doesn’t have to do any work where there are 0’s, so it is really fast. In fact, that 7x7 = 49 multiplies is reduced to 7 + 7 = 14 multiplies. At the larger radius, these advantages become really obvious.

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0.011 0.135 0.607 1.000 0.607 0.135 0.011
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 2.506, offset = 0 or use autoscale)
                            Horizontal Blur, radius = 1

                            0 0 0 0.011 0 0 0
                            0 0 0 0.135 0 0 0
                            0 0 0 0.607 0 0 0
                            0 0 0 1.000 0 0 0
                            0 0 0 0.607 0 0 0
                            0 0 0 0.135 0 0 0
                            0 0 0 0.011 0 0 0 (scale = 2.506, offset = 0 or use autoscale)
                            Vertical Blur, radius = 1

                            So if you did both of them to your image, and the order doesn’t matter, you’d get almost exactly the same effect as the built-in Gaussian function.

                            Edge Enhancing II – The Laplacian

                            Earlier we saw that a directional derivative was really the same thing as embossing, and if we took the directional derivative in several directions and kept the biggest value, we’d find the edges. There is a different way that came first. This is called the Laplacian, after the guy. If you’ve got a math background, this is really the second derivative.

                            Let’s start with the simplest version of the Laplacian:

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 -1 0 0 0
                            0 0 -1 4 -1 0 0
                            0 0 0 -1 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 1, offset = 128)

                            (You could also use scale = 4 if you’re following the Scale & Offset Rule from the last post.)

                            This will trace every edge and highlight every bit of noise in your entire image. In fact, the Laplacian is the best noise amplifier of all of the edge detectors.

                            There is an additive version of that kernel (notice the different center value and that Offset = 0):

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 -1 0 0 0
                            0 0 -1 5 -1 0 0
                            0 0 0 -1 0 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 1, offset = 0)

                            What I did was add the original image back to the edge image. You could use the FADE tool here to get as much emphasis as you want… if you like noise, that is.
                            However, if you had some kind of QuickMask (Selection) that isolated the processing to where the edges are… Nevermind. We’ll talk about that some other time.

                            This kernel setting works because the sum of the positive values is one more than the sum of the negative values. Because the difference is just one, I can use scale = 1, offset = 0. This causes a uniform area on the image to be unchanged.

                            Back with the –1’s and the 4, the positive sum was the same as the negative sum so a uniform area on the image would give a zero and it was possible to get negatives, so we used an offset=128 to put the unchanging values in the middle of the histogram.

                            One other Laplacian kernel is used fairly often because it emphasizes diagonals, too:

                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0
                            0 0 -1 -1 -1 0 0
                            0 0 -1 8 -1 0 0
                            0 0 -1 -1 -1 0 0
                            0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 (scale = 8 or 1, offset = 128)

                            If you replace the 8 in the middle with a 9, set scale = 1, offset = 0.

                            I’m running out of time. Next time we’ll do a High Pass filter which is basically subtracting the blurred image from the original, show how that is related to the UnSharp Mask (and where the USM came from) and we’ll go from there.

                            -Chris Russ
                            Last edited by jcr6; 10-24-2002, 07:14 AM.

                            Comment


                            • #15
                              Wow - thanks again Chris, you are really helping with your posts on convolution and I appreciate you sharing your time and knowledge on this topic.

                              I don't want to sidetrack your posts, but I have a link to some custom convolution kernels for sub pixel motion simulation for anyone following this thread to experiment with:

                              http://www.retouchpro.com/forums/sho...4352#post34352

                              P.S. PC users should add a .acf file name extension to the downloaded kernel files if it is missing (Photoshop, Adobe Custom Filter preset file extension).

                              Stephen Marsh.

                              Comment

                              Related Topics

                              Collapse

                              • Doug Nelson
                                Filter Forge
                                by Doug Nelson
                                "On the surface, Filter Forge is just a Photoshop plugin, a pack of filters that generate textures, create visual effects, enhance photos, process images. However, there are 3 things that make Filter Forge unique:

                                1. You can create your own filters. Filter Forge comes with a visual
                                ...
                                05-25-2006, 02:38 PM
                              • Craig Walters
                                Brief Filter Forge Review
                                by Craig Walters
                                Filter Forge is a pretty amazing program. It makes filters for Photoshop and other programs that can use the .8bf plug-in types.

                                The biggest draw of this program is that you don't have to know how to code. It's visual and comes in two parts, the Graphical User Interface (or GUI) and...
                                11-09-2007, 03:05 PM
                              • Andrew B.
                                Filter Forge becomes less expensive
                                by Andrew B.
                                Filter Forge has added two less-expensive versions of their software.

                                Basic edition costs $99 and allows full use of all filters in the library. As I am typing this there are 2265 filters in the library, and the number is always growing.

                                Standard edition costs $199, and...
                                05-17-2007, 11:13 PM
                              • hawkeye60
                                Multiple filter listings Photoshop 7
                                by hawkeye60
                                I wondered if anyone has seen this behavior in Photoshop. Double listings for Extract, Liquify and Pattern Maker. I've had this happen on several occasions, but I have no idea what the cause might be.
                                Everything still functions normally, just double listings....
                                04-23-2008, 08:20 PM
                              • KR1156
                                Custom Filter
                                by KR1156
                                Does anyone have a good understanding of the Custom filter in ps?

                                I heard you can do some really nice sharpening through this method, with minimal halos.
                                08-25-2006, 10:03 AM
                              Working...
                              X