List of my modules...
Module: Channel Network process
Description:
Processes a network channel, by smoothing and/or merging... Generates a new network channel.
The smoothing is a simple weigthed average, with an ajustable window for the endpoints. If the channel points are named p1, p2, ... , pn, then the following defines the smoothing:
where σ is the strength of the smoothing, defined in port Strength. The size of the window for the endpoints (the w in the above formulae) is defined in port Smooth_window.
Each channel is smoothed separately, which means the new intersection points positions will be an average from the smoothing of the connecting branches.
The merging process is an alignment test: if the directions at the endpoints of two branches differ by less than a certain threshold (the Angle port, in degrees), then they are merged. The direction is the normalised vector p1 - p1+w for the first endpoint, pn - pn-w for the other. Of course when measuring the angular difference, one is inverted.
Illustration of the processing. The starting data, on the left, is a network generated from a skeleton converted to a graph, then to a channel network (Skeletonise, Skeleton_Image_To_Graph, and Skeleton_Graph_To_Channel_Network), which explains the zig-zags. The middle image is the result of a smoothing (3 passes, 0.5 strength). Notice that some intersections are still a bit pinched. The right image is the result of the merging (6 point window, 40° angle threshold), creating two long vertical channels.
Notes
- Radius associated with each point not affected by smoothing.
- Smoothing strength close to 1 will have adverse anti-smoothing effects. Typically a value of 0.5 is fine.
- Selecting nothing in the Type port will just copy input to output.
- If the merging is still tricky at strongly pinched intersections (e.g. lower left intersection in above example), and you don't want to increase the angle threshold too much, you can either do another round of smoothing before merging and output the unsmoothed merged version, or increase angle measurement window size.
Connections:
Channel_Network
[required]
The input channel network, of type HxChannelNetwork.
Ports:
Type

Type of processing requested. Note that if both are selected, the merging will be performed on the smoothed network.
Strength

If smooth is selected in the Type port, then this value between 0 and 1 defines the strength. It's the σ in the above equations.
Smooth_window

Window size to find the gradient at the branch endpoints. It's the w in the above equations.
Passes

Number of times the smoothing operation is performed.
Merge_window

If merge is selected in the Type port, defines the window size to find the gradient at the branch endpoints, exactly the same as Smooth_window.
Angle

Branches are merged provided their directions differ by strictly less than this value.
Options

Select this option if you want the merging on a smoothed version of the network but keep the original positions of the points.
Action button

Push the button to start the computation.
Commands:
Additional options can be accessed when typing in the console Channel_Network_Process COMMAND_NAME. Typing the command again usually reverts back to original settings.
verbose
Displays timing and other information after the computation. Retype to hide info.
create
Runs the computation. Returns the name of the output, so it can be used in a script, such as set RESULT [Channel_Network_Process create].