Game Development Reference
In-Depth Information
enum minmax_t { MIN_FLT, MAX_FLT };
struct minmax_impl_t {
float2 uv_;
float2 p_;
float v_;
__device__ minmax_impl_t( float2 uv) {
uv_ = p_= uv;
v_ = tex2D (texL, uv.x, uv.y);
}
template <minmax_t T>
__device__ void add( float2 p) {
float L= tex2D (texL, p.x, p.y);
if ((T == MAX_FLT) && (L > v_)) {
p_=p;
v_=L;
}
if ((T == MIN_FLT) && (L < v_)) {
p_=p;
v_=L;
}
}
template <minmax_t T>
__device__ void run( float2 n, float radius ) {
float ds;
float2 dp;
float2 nabs = fabs(n);
if (nabs.x > nabs.y) {
ds = 1.0f / nabs.x;
dp = make_float2 (0, 0.5f - 1e-3);
} else {
ds = 1.0f / nabs.y;
dp = make_float2 (0.5f - 1e-3, 0);
}
for ( float d = ds; d <= radius; d += ds ) {
float2 o = d*n;
add<T>(uv_ + o + dp);
add<T>(uv_ + o - dp);
add<T>(uv_ - o + dp);
add<T>(uv_ - o - dp);
}
}
};
Listing 5.8. Implementation of the gradient-directed minimum and maximum filters.
the creation of shocks in almost smooth regions. The quality of the output is
comparable to that of the coherence-enhancing shock filter, but computationally
the gradient-directed shock filter is much more ecient. It only requires the
smoothed structure tensor and the input image converted to grayscale. For the
sake of simplicity, the FLoG and the minimum and maximum filters have been
 
 
Search Nedrilad ::




Custom Search