Re: need some help with custom filter in Photoshop
From: Anders Thulin (ath_no_spam_please_at_algonet.se)
Date: 02/27/05
- Next message: Amyotte: "Re: Newbie Dob again..."
- Previous message: Tim Killian: "Re: Macs in Astronomy Updated; Canon 20D under Mac & Windows"
- In reply to: Blaine Waddington: "need some help with custom filter in Photoshop"
- Next in thread: Blaine Waddington: "Re: need some help with custom filter in Photoshop"
- Reply: Blaine Waddington: "Re: need some help with custom filter in Photoshop"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Feb 2005 08:42:55 GMT
Blaine Waddington wrote:
> I keep running into these "custom" or kernal filters in Photoshop and other
> programs but, try as I might, I have been unable to find good tutorials as
> to how they work with some practical input values.
A textbook in image processing perhaps? *Real* image processing, not
image editing or synthesizing. (I remember Gonzales & Wintz from way back, but
Gonzales & Woods probably replaces that nowadays.)
Kernels are square arrays (typically of odd sizes, like 3x3) containing a
number of specially selected coeffiecents. The size is the 'input area',
the coefficients the weighting of the corresponding pixels in the input image,
and the actual function being performed over these pixels is typically
summing follwoed by a scaling operation implicit in the kernel. Output is
one single pixel orresponding to the center of the kernel.
Processing is done by placing the kernel in all possible positions on the
input image, and creating an output image from the input pixels. (image
edges get special treatment.) For example (3x3 kernel, with coordinate [0,0] in the center):
out[x,y] := sum of (in[x-1,y-1]*kernel[-1,-1], ..., in[x+1,y+1]*kernel[1,1]);
Each pixel gets multiplied with the corresponding kernel coefficient, and the result is
summed.
If the kernel is all 1, and you add a division by 9 at the end, this is a simple
averaging filter (remember, pixels are from input image only). By changing the kernel,
you can weight pixels to influence the outcome more (though you may need to change the
9 accordingly). For instance, corner pixels may get weight 1, orthogonal pixels weight
4, central pixel weight 9 -- this filter is slightly more spatially sensitive than
the 'all 1' one.
You can also use kernels for feature detection, such as edge detection.
If kernel is [[-1,-1,-1],[-1,8,-1],[-1,-1,-1]], you'll get a
resulting image that is all edges from the original image, i.e. places
where a low pixel value was next to a high pixel, regardless of direction
(though within the spatial limitations of a 3x3 kernel).
If you change that to [-1,8,-1][-1,8,-1][-1,8,-1], you'll
enhance narrow vertical lines. Typically, the results from several
such 'convolutions' are combined for further processing, and possibly
even used as input images for higher-level convolutions.
3x3 pixels are a bit too primitive, though -- 5x5 or 7x7 often makes for
better results, but of course requires much more processing power.
For these sizes, you need hardware assist ... or specialized hardware.
In a past life, I worked with a company where 11x11 kernels were thought
of as barely useful -- 19x19 and above were more like real life.
If you want to go deeper, look for the term 'convolution' in the context
of image processing. You may need some math background, though.
-- Anders Thulin ath*algonet.se http://www.algonet.se/~ath
- Next message: Amyotte: "Re: Newbie Dob again..."
- Previous message: Tim Killian: "Re: Macs in Astronomy Updated; Canon 20D under Mac & Windows"
- In reply to: Blaine Waddington: "need some help with custom filter in Photoshop"
- Next in thread: Blaine Waddington: "Re: need some help with custom filter in Photoshop"
- Reply: Blaine Waddington: "Re: need some help with custom filter in Photoshop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|