www.pudn.com > GPU-KLT-1.0.zip > klt_detector_nonmax.cg


/*
Copyright (c) 2008 University of North Carolina at Chapel Hill

This file is part of GPU-KLT.

GPU-KLT is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

GPU-KLT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along
with GPU-KLT. If not, see .
*/

#ifndef MIN_DIST
# define MIN_DIST 5
#endif

void main(uniform sampler2D src_tex : TEXUNIT0,
          float2 st0 : TEXCOORD0,
          uniform float2 ds,
          out float4 color : COLOR)
{
   // A final value < 0 indicates, that the maximum value was from the neighboring pixels.

   float maxCornerness = pack_4ubyte(tex2D(src_tex, st0));

   for (int i = -MIN_DIST; i < 0; ++i)
   {
      float cornerness = abs(pack_4ubyte(tex2D(src_tex, st0 + i*ds)));
      maxCornerness = (cornerness >= abs(maxCornerness)) ? (-cornerness) : maxCornerness;
   }

   for (int i = 1; i <= MIN_DIST; ++i)
   {
      float cornerness = abs(pack_4ubyte(tex2D(src_tex, st0 + i*ds)));
      maxCornerness = (cornerness >= abs(maxCornerness)) ? (-cornerness) : maxCornerness;
   }

   color = unpack_4ubyte(maxCornerness);
}