It's been
a few weeks since we last worked in the Photoshop Filter Factory.
If you haven't read the first two parts of this series, it would
probably be advisable for you to do so. In Part
1, we look at the basics of Filter Factory, along with a
few examples of how to get some basic effects working by manipulating
color channels. In
Part 2, we used ResEdit to customize the interfaces of the
Filter we created. Now we're going to go a little deeper into
what Filter Factory can do to help you create your own Photoshop
filters.
If you remember
your terminology, you'll recall that we left off with two functions
and four operators. Operators are things like multiplication,
division, addition and subtraction. Functions we covered included
"src" for evaluating and manipulating pixel positions
and "rnd" for creating noise effects. Today we're
going to take a look at a few new variables, several new functions
and one conditional statement.
Don't worry.
Just as in Part 1, we're not going to be doing any real programming.
Just playing with some numbers and learning to mind our parenthetical
expressions.
Convolution
The first thing we're going to do here is a little function
that can generate a whole lot of effects, from blurs to more
psychedelic effects. This is a function that looks at a pixel
then looks at its surrounding pixels and does something to the
whole lot of them. The way you write out a convolve expression
is like this:
cnv(topleft,topcenter,topright,middleleft,middlecenter,middleright,bottomleft,bottomcenter,bottomright,divisor)
That is
to say, you assign a value for each pixel surrounding the center
pixel, and the values are divides by the divisor. First let's
just try a simple application of this principle by blurring
the image. This is accomplished like by placing the following
expression in each of the R, G and B channels: cnv(0,1,0,1,4,1,0,1,0,8).
(Remember, you can copy and paste expressions from here to the
Filter Factory, so you don't have to type things manually.)
That wasn't
so tough. So how could we take this function a step further?
Well, we don't want to put our sliders to waste, do we? So let's
just substitute slider values for regular, old numbers. We only
have eight sliders, though, so we'll have to repeat them for
now. So try: cnv(ctl(0),ctl(1),ctl(2),ctl(3),ctl(3),ctl(3),ctl(4),ctl(5),ctl(6),ctl(7))
and play around with the sliders. Notice that the divisor (ctl(7))
has the most impact on the way the other sliders behave. This
is because any values you select in the first six sliders are
added together and divided by the last.
So that's
pretty fancy. But we can also bring in one of the functions
we learned in Part 1 to make the thing do some even funkier
stuff. (And I do mean funk-ay.) The function we used in Part
1 was "src" to tell Filter Factory what to do with
the individual pixels and their positions in each channel. So
now let's try wrapping this src function around our cnv function.
That is to say, with a source function, we have src(x,y,channel).
(Channel is represented as a number 0 through three for red,
green, blue and alpha, respectively.) Instead of x and y, let's
use the convolve expression. It will basically be cnv(expression,expression,channel).
Try this one, remembering to separate each expression with a
comma and remembering to put the correct channel number at the
end:
R: src(cnv(ctl(0),ctl(0),ctl(0),ctl(0),ctl(0),ctl(0),ctl(0),ctl(0),ctl(0),ctl(6)),
cnv(ctl(1),ctl(1),ctl(1),ctl(1),ctl(1),ctl(1),ctl(1),ctl(1),ctl(1),ctl(7)),0)
G: src(cnv(ctl(2),ctl(2),ctl(2),ctl(2),ctl(2),ctl(2),ctl(2),ctl(2),ctl(2),ctl(6)),
cnv(ctl(3),ctl(3),ctl(3),ctl(3),ctl(3),ctl(3),ctl(3),ctl(3),ctl(3),ctl(7)),1)
B: src(cnv(ctl(4),ctl(4),ctl(4),ctl(4),ctl(4),ctl(4),ctl(4),ctl(4),ctl(4),ctl(6)),
cnv(ctl(5),ctl(5),ctl(5),ctl(5),ctl(5),ctl(5),ctl(5),ctl(5),ctl(5),ctl(7)),2)
Here's
what it might look like, depending upon your slider settings:
The original
image (top) and two convolve
filters using the expressions above.
Again, ctl(6)
and ctl(7), otherwise known as sliders 7 and 8, will have the
most impact on the final result, since the other sliders are
added up and divided by them. Tweak around with it for some
psychedelic effects.