View Single Post
Old 23rd August 2005, 21:16   #23  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Quote:
Originally Posted by Didée
Okay ... here my little suggestion for inpand and expand:

As noted, it would be nice to have the possibility to in/expand only horizontally, or only vertically. When working e.g. with comb masks, or horizontal-only/vertical-only edgemasks, the advantages are obvious.

Plus there's one thing more behind it. When internal code for one-dimensional in/expanding is available, then an additional operation could be implemented: a merging of [normal expand] + [horizontal+vertical expand].
Why? to get "round corner" expanding. Currently, a chain of 10*expand() will turn e.g. a point into a 21*21 square. With "round corner" expanding, one would get a circle of diameter 21. There are cases where this would be desireable, because the "distance" of the filtering is of equal length in all directions, then. For simple expanding, there is a distance deviation of sqrt(2) - - too long in diagonal direction.
The following filters can be implemented:
Code:
ShapeMax(clip input, string "Yshape", string "Ushape", string "Vshape")
ShapeMin(clip input, string "Yshape", string "Ushape", string "Vshape")
ShapeAverage(clip input, string "Yshape", string "Ushape", string "Vshape")
Here Yshape is a string containing pairs of numbers describing a shape. This shape is then translated from (0,0) to any point in the frame, then for each point the maximum over the translated shape is taken to calculate the pixel values of ShapeMax. ShapeMin and ShapeAverage are similar. Of course, for pixels near the boundary not all points of the translated shift are inside the frame. Execution time increases linearily with the number of points of the shape.
While shape strings can be written by hand, it is convenient to have generating function for such strings. It is easy to implement functions like
Code:
Circle(R)
which returns a shape string for a circle with radius R.
kassandro is offline   Reply With Quote