25 #include "LinearRegionDetector.hh"
26 #include <Base/Image/ImageConvert.hh>
28 #include <Base/Image/ImageIO.hh>
32 #define MIN_EIGENVALUE_RATIO 4.0
33 #include <Base/Debug/TimeMeasure.hh>
46 template <
class StorageType,
class CalculationType>
54 template <
class StorageType,
class CalculationType>
64 template <
class StorageType,
class CalculationType>
70 BIASASSERT(this->_Cornerness.SamePixelAndChannelCount(this->_sgxx));
71 BIASASSERT(this->_Cornerness.SamePixelAndChannelCount(mineig));
73 int tlx, tly, brx, bry;
74 this->_sgxx.GetROI()->GetCorners(tlx, tly, brx, bry);
82 register double gxx, gyy, gxy, ev1, ev2;
83 register const double me=(double)this->_MinCornerness;
84 Feat fp; this->_FeatList.clear();
85 this->_FeatList.reserve((brx-tlx)*(bry-tly));
87 register CalculationType **isgxx=this->_sgxx.GetImageDataArray();
88 register CalculationType **isgxy=this->_sgxy.GetImageDataArray();
89 register CalculationType **isgyy=this->_sgyy.GetImageDataArray();
92 for (y=miny; y<maxy; y++){
93 for (x=minx; x<maxx; x++){
94 gxx=(double)(isgxx[y][x]);
95 gyy=(double)isgyy[y][x];
96 gxy=(double)isgxy[y][x];
97 double tmpsqrt = sqrt((gxx - gyy)*(gxx - gyy)+4.0*gxy*gxy);
98 ev1=((gxx+gyy+tmpsqrt)/2.0);
99 ev2=((gxx+gyy-tmpsqrt)/2.0);
100 ime[y][x]=(CalculationType)fabs(ev1/ev2);
101 if ((fabs(ev1/ev2)>MIN_EIGENVALUE_RATIO) && (ev1>me)){
103 for (
int i=-2; i<3; i++)
104 for (
int j=-2; j<3; j++)
105 gg += (gxx-isgxx[y+i][x+j])*(gxx-isgxx[y+i][x+j])
106 +(gyy-isgyy[y+i][x+j])*(gyy-isgyy[y+i][x+j])
107 +(gxy-isgxy[y+i][x+j])*(gxy-isgxy[y+i][x+j]);
112 fp.val=(ev1>(double)INT_MAX)?(INT_MAX):((
int)ev1);
113 this->_FeatList.push_back(fp);
119 if (this->DebugLevelIsSet(D_CD_WRITE_DEBUG_IM)){
136 #ifdef BUILD_IMAGE_INT
139 #ifdef BUILD_IMAGE_CHAR
141 #ifdef BUILD_IMAGE_SHORT
143 #ifdef BUILD_IMAGE_USHORT
144 #ifdef BUILD_IMAGE_INT
148 #ifdef BUILD_IMAGE_UINT
150 #ifdef BUILD_IMAGE_DOUBLE
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
try to detect linear regions (const gradient) in images, experimental code for testing ...
virtual int _ComputeCornerness(Image< CalculationType > &im)
Computes the larger eigenvalue of the structure tensor points are accepted only if smaller eigenvalue...
ROI * GetROI()
Returns a pointer to the roi object.
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
base class for all gradient based corner detectors
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase