00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "SUSANEdgeDetectionLite.h"
00010
00011 SUSANEdgeDetectionLite::SUSANEdgeDetectionLite(int edgeThreshold)
00012 {
00013 setupSusanLUT(edgeThreshold);
00014 }
00015
00016 SUSANEdgeDetectionLite::~SUSANEdgeDetectionLite(){};
00017
00018
00019 void SUSANEdgeDetectionLite::setupSusanLUT(int threshold)
00020 {
00021 unsigned char temp;
00022 for (int k=127; k<255; k++) {
00023 temp = (unsigned char) (255*exp((double)(-pow(((k-126)<<1)/threshold,6))));
00024 Susan_LUT[k] = temp;
00025 Susan_LUT[254-k] = temp;
00026 }
00027 }
00028
00029
00030 bool SUSANEdgeDetectionLite::isEdgePoint(const Image& image, int posx, int posy, ColorSpectra channel) const
00031 {
00032 register int counter;
00033 register unsigned char center;
00034 unsigned char neighbours0;
00035 unsigned char neighbours1;
00036 unsigned char neighbours2;
00037 unsigned char neighbours3;
00038 unsigned char neighbours4;
00039 unsigned char neighbours5;
00040 unsigned char neighbours6;
00041 unsigned char neighbours7;
00042
00043 int sp = static_cast<int> (channel);
00044
00045 center = image.image[posy][sp][posx];
00046 neighbours0 = image.image[posy-1][sp][posx];
00047 neighbours1 = image.image[posy+1][sp][posx];
00048 neighbours2 = image.image[posy][sp][posx-1];
00049 neighbours3 = image.image[posy][sp][posx+1];
00050 neighbours4 = image.image[posy-1][sp][posx-1];
00051 neighbours5 = image.image[posy+1][sp][posx-1];
00052 neighbours6 = image.image[posy-1][sp][posx+1];
00053 neighbours7 = image.image[posy+1][sp][posx+1];
00054
00055 counter = correlation(neighbours0-center);
00056 counter += correlation(neighbours1-center);
00057 counter += correlation(neighbours2-center);
00058 counter += correlation(neighbours3-center);
00059 counter += correlation(neighbours4-center);
00060 counter += correlation(neighbours5-center);
00061 counter += correlation(neighbours6-center);
00062 counter += correlation(neighbours7-center);
00063
00064 if (counter<GEOMETRIC_THRESHOLD)
00065 return true;
00066 else
00067 return false;
00068 };
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085