#include "HxImageRep.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxDistanceTransform (HxImageRep img) |
Distance transform replaces each pixel of an object with an estimate of its shortest distance to the background (the distance to the nearest background pixel). More... |
|
Distance transform replaces each pixel of an object with an estimate of its shortest distance to the background (the distance to the nearest background pixel). Background is defined as all pixels with value 0.
00086 { 00087 HxImageRep input = BinMap(HxImageAsDouble(img), inf, 0); 00088 00089 double filterData[] = { 00090 inf, sqrt_5, inf, sqrt_5, inf, 00091 sqrt_5, sqrt_2, 1, sqrt_2, sqrt_5, 00092 inf, 1, 0, 1, inf, 00093 sqrt_5, sqrt_2, 1, sqrt_2, sqrt_5, 00094 inf, sqrt_5, inf, sqrt_5, inf 00095 }; 00096 HxImageRep kernel = HxMakeFromDoubleData(1, 2, HxSizes(5, 5, 1), filterData); 00097 00098 return input.recursiveNeighOp(kernel, "add", "minAssign"); 00099 } |