diff --git a/Code/FBSD/BlurredSegment/bstracker.cpp b/Code/FBSD/BlurredSegment/bstracker.cpp index f392344dfb6fb8add0cce108935a1b0112c8af0b..705c4ee2ee65dc5641cd7cb3e3aaa48181713cad 100755 --- a/Code/FBSD/BlurredSegment/bstracker.cpp +++ b/Code/FBSD/BlurredSegment/bstracker.cpp @@ -255,7 +255,7 @@ BlurredSegment *BSTracker::fineTrack (int bsMaxWidth, // Handles assigned thickness control if (atcOn && stableWidthCount >= assignedThicknessControlDelay) { - EDist finalWidth (bs.digitalThickness().sumHalf ()); + EDist finalWidth (bs.digitalThickness().sumWithOneHalf ()); if (finalWidth.lessThan (bs.getMaxWidth ())) bs.setMaxWidth (finalWidth); atcOn = false; } diff --git a/Code/FBSD/FBSD.pro b/Code/FBSD/FBSD.pro index 9ab03401e30927b04cb865ea88419aba63b15a49..289db6e79a7f92e5ea1588a9210229249e4bccd7 100644 --- a/Code/FBSD/FBSD.pro +++ b/Code/FBSD/FBSD.pro @@ -53,7 +53,6 @@ HEADERS += BlurredSegment/biptlist.h \ ImageTools/digitalstraightsegment.h \ ImageTools/edist.h \ ImageTools/pt2i.h \ - ImageTools/strucel.h \ ImageTools/vmap.h \ ImageTools/vr2i.h SOURCES += main.cpp \ @@ -96,6 +95,5 @@ SOURCES += main.cpp \ ImageTools/digitalstraightsegment.cpp \ ImageTools/edist.cpp \ ImageTools/pt2i.cpp \ - ImageTools/strucel.cpp \ ImageTools/vmap.cpp \ ImageTools/vr2i.cpp diff --git a/Code/FBSD/IPOLdemo/IPOLdemo.pro b/Code/FBSD/IPOLdemo/IPOLdemo.pro index 9ba8e41b3362dd9b1bde73af22feddb9ebedad4f..5e70befdaf13465dcc0d4f1d74b5941e501cc5d0 100644 --- a/Code/FBSD/IPOLdemo/IPOLdemo.pro +++ b/Code/FBSD/IPOLdemo/IPOLdemo.pro @@ -16,10 +16,10 @@ OBJECTS_DIR = obj # Input HEADERS += ../BlurredSegment/biptlist.h \ ../BlurredSegment/blurredsegment.h \ - ../BlurredSegment/blurredsegmentproto.h \ ../BlurredSegment/bsdetector.h \ + ../BlurredSegment/bsproto.h \ ../BlurredSegment/bstracker.h \ - ../BlurredSegment/bsfilter.h \ + ../BlurredSegment/nfafilter.h \ ../ConvexHull/antipodal.h \ ../ConvexHull/chvertex.h \ ../ConvexHull/convexhull.h \ @@ -40,17 +40,17 @@ HEADERS += ../BlurredSegment/biptlist.h \ ../ImageTools/absrat.h \ ../ImageTools/digitalstraightline.h \ ../ImageTools/digitalstraightsegment.h \ + ../ImageTools/edist.h \ ../ImageTools/pt2i.h \ - ../ImageTools/strucel.h \ ../ImageTools/vmap.h \ ../ImageTools/vr2i.h SOURCES += mainIPOL.cpp \ ../BlurredSegment/biptlist.cpp \ ../BlurredSegment/blurredsegment.cpp \ - ../BlurredSegment/blurredsegmentproto.cpp \ ../BlurredSegment/bsdetector.cpp \ + ../BlurredSegment/bsproto.cpp \ ../BlurredSegment/bstracker.cpp \ - ../BlurredSegment/bsfilter.cpp \ + ../BlurredSegment/nfafilter.cpp \ ../ConvexHull/antipodal.cpp \ ../ConvexHull/chvertex.cpp \ ../ConvexHull/convexhull.cpp \ @@ -68,10 +68,9 @@ SOURCES += mainIPOL.cpp \ ../DirectionalScanner/vhscannero2.cpp \ ../DirectionalScanner/vhscannero7.cpp \ ../DirectionalScanner/vhscannero8.cpp \ - ../ImageTools/absrat.cpp \ ../ImageTools/digitalstraightline.cpp \ ../ImageTools/digitalstraightsegment.cpp \ + ../ImageTools/edist.cpp \ ../ImageTools/pt2i.cpp \ - ../ImageTools/strucel.cpp \ ../ImageTools/vmap.cpp \ ../ImageTools/vr2i.cpp diff --git a/Code/FBSD/IPOLdemo/mainIPOL.cpp b/Code/FBSD/IPOLdemo/mainIPOL.cpp index d16a13340cce8265bd91b66a183d7e7a3feea844..7c8016fb2e40c8811b2bf49f5bdf3b43b7187055 100755 --- a/Code/FBSD/IPOLdemo/mainIPOL.cpp +++ b/Code/FBSD/IPOLdemo/mainIPOL.cpp @@ -138,16 +138,6 @@ int main (int argc, char *argv[]) } } -/* -AbsRat x1, y1, x2, y2; -vector<BlurredSegment *> bss = detector.getBlurredSegments (); -vector<BlurredSegment *>::const_iterator it = bss.begin (); -while (it != bss.end ()) -{ - DigitalStraightSegment *dss = (*it)->getSegment (); - dss->naiveLine (x1, y1, x2, y2); -*/ - vector<BlurredSegment *>::const_iterator it = bss.begin (); while (it != bss.end ()) { @@ -168,23 +158,6 @@ while (it != bss.end ()) } foutAllPts<< std::endl; - // Affichage du DSS englobant - // vector<Pt2i> bnd; - // DigitalStraightSegment *dss = (*it)->getSegment (); - // if (dss != NULL) - // { - - // dss->getBounds (bnd, 0, 0, width, height, false); - // // cout << "DSS starts from (" << bnd.front().x() - // // << "," << bnd.front().y() << ")" << endl; - // auto b = bnd.begin(); - // for (auto &x: bnd){ - // cout << "DSS starts from (" << x.x() - // << "," << x.y() << ")" << endl; - - // } - // } - it++; } @@ -222,23 +195,6 @@ while (it != bss.end ()) } foutAllPts<< std::endl; - // Affichage du DSS englobant - // vector<Pt2i> bnd; - // DigitalStraightSegment *dss = (*it)->getSegment (); - // if (dss != NULL) - // { - - // dss->getBounds (bnd, 0, 0, width, height, false); - // // cout << "DSS starts from (" << bnd.front().x() - // // << "," << bnd.front().y() << ")" << endl; - // auto b = bnd.begin(); - // for (auto &x: bnd){ - // cout << "DSS starts from (" << x.x() - // << "," << x.y() << ")" << endl; - - // } - // } - it++; } } diff --git a/Code/FBSD/ImageTools/edist.cpp b/Code/FBSD/ImageTools/edist.cpp index 398fbb3fac8789cda26fd39f631a3df4303b88e2..eecca1114a58a94dd4deb2335a4bb9cff8d11ca1 100644 --- a/Code/FBSD/ImageTools/edist.cpp +++ b/Code/FBSD/ImageTools/edist.cpp @@ -20,20 +20,3 @@ EDist::EDist (const EDist &dist) d_num = dist.d_num; d_den = dist.d_den; } - - -void EDist::attractsTo (const EDist &val, const EDist &ratio) -{ - if (val.d_den != 0) - d_num = (int) ((ratio.d_den * ((int64_t) d_num) * val.d_den - - (((int64_t) d_num) * val.d_den - - ((int64_t) d_den) * val.d_num) * ratio.d_num) - / (ratio.d_den * (int64_t) (val.d_den))); -} - - -void EDist::sticksTo (const EDist &val) -{ - if (val.d_den != 0) - d_num = (int) ((d_den * ((int64_t) (val.d_num))) / val.d_den); -} diff --git a/Code/FBSD/ImageTools/edist.h b/Code/FBSD/ImageTools/edist.h index ba5a4a6323ec1437a42c204f3ca52c1f32a71022..633c57616e7b8ba9d20d18e7c45e328baa35f19d 100644 --- a/Code/FBSD/ImageTools/edist.h +++ b/Code/FBSD/ImageTools/edist.h @@ -121,24 +121,6 @@ public: inline bool greaterEqThan (const EDist &dist) const { return (d_num * (int64_t) (dist.d_den) >= d_den * (int64_t) (dist.d_num)); } - /** - * \brief Attracts the rational number to another one with given ratio. - * Withdraws to the rational number A - * the difference between the rational number A and an attractor number V - * multiplied by the ratio R: A -> A - (A - V) * R - * The denominator is left unchanged. - * @param val Goal rational value (denominator should not be null). - * @param ratio Attraction ratio. - */ - void attractsTo (const EDist &val, const EDist &ratio); - - /** - * \brief Sets numerator of the rational number to approach given number. - * The denominator is left unchanged. A -> V - * @param val Given rational number (denominator should not be null). - */ - void sticksTo (const EDist &val); - /** * \brief Multiplies the Euclidean distance by another one. * @param dist Other Euclidean distance. @@ -156,7 +138,7 @@ public: /** * \brief Returns the sum of the Euclidean distance and 1/2. */ - inline EDist sumHalf () const { + inline EDist sumWithOneHalf () const { return (d_den % 2 == 1 ? EDist (2 * d_num + d_den, 2 * d_den) : EDist (d_num + d_den / 2, d_den)); } diff --git a/Code/FBSD/ImageTools/strucel.cpp b/Code/FBSD/ImageTools/strucel.cpp deleted file mode 100755 index e4d38703db52d39cf2d8a0644851b60e66ccf3fa..0000000000000000000000000000000000000000 --- a/Code/FBSD/ImageTools/strucel.cpp +++ /dev/null @@ -1,233 +0,0 @@ -#include "strucel.h" - -const int Strucel::TYPE_PLUS_3X3 = 0; -const int Strucel::TYPE_HOR = 1; -const int Strucel::TYPE_VER = 2; - - -Strucel::Strucel (int type) -{ - if (type == TYPE_PLUS_3X3) - { - width = 3; - height = 3; - size = 5; - pattern = new Vr2i[5]; - pattern[0].set (0, 0); - pattern[1].set (0, 1); - pattern[2].set (-1, 0); - pattern[3].set (1, 0); - pattern[4].set (0, -1); - } - else if (type == TYPE_HOR) - { - width = 3; - height = 1; - size = 3; - pattern = new Vr2i[3]; - pattern[0].set (0, 0); - pattern[1].set (0, 1); - pattern[2].set (0, -1); - } - else if (type == TYPE_VER) - { - width = 1; - height = 3; - size = 3; - pattern = new Vr2i[3]; - pattern[0].set (0, 0); - pattern[1].set (1, 0); - pattern[2].set (-1, 0); - } - else - { - width = 1; - height = 1; - size = 1; - pattern = new Vr2i[1]; - pattern[0].set (1, 1); - } -} - - -Strucel::~Strucel () -{ - delete pattern; -} - - -void Strucel::tophatGradient (int *out, unsigned char *in, - int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (min == -1 || in[y * width + x] < min) min = in[y * width + x]; - } - out[j * width + i] = in[j * width + i] - min; - } -} - - -void Strucel::tophatGradient (int *out, int *in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (min == -1 || in[y * width + x] < min) min = in[y * width + x]; - } - out[j * width + i] = in[j * width + i] - min; - } -} - - -void Strucel::tophatGradient (int *out, int **in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (min == -1 || in[y][x] < min) min = in[y][x]; - } - out[j * width + i] = in[j][i] - min; - } -} - - -void Strucel::blackhatGradient (int *out, unsigned char *in, - int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (in[y * width + x] > max) max = in[y * width + x]; - } - out[j * width + i] = max - in[j * width + i]; - } -} - - -void Strucel::blackhatGradient (int *out, int *in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (in[y * width + x] > max) max = in[y * width + x]; - } - out[j * width + i] = max - in[j * width + i]; - } -} - - -void Strucel::blackhatGradient (int *out, int **in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - if (in[y][x] > max) max = in[y][x]; - } - out[j * width + i] = max - in[j][i]; - } -} - - -void Strucel::morphoGradient (int *out, unsigned char *in, - int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - { - if (min == -1 || in[y * width + x] < min) min = in[y * width + x]; - if (in[y * width + x] > max) max = in[y * width + x]; - } - } - out[j * width + i] = max - min; - } -} - - -void Strucel::morphoGradient (int *out, int *in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - { - if (min == -1 || in[y * width + x] < min) min = in[y * width + x]; - if (in[y * width + x] > max) max = in[y * width + x]; - } - } - out[j * width + i] = max - min; - } -} - - -void Strucel::morphoGradient (int *out, int **in, int width, int height) -{ - for (int j = 0; j < height; j++) - for (int i = 0; i < width; i++) - { - int max = 0; - int min = -1; - for (int k = 0; k < size; k++) - { - int x = i - pattern[k].x (); - int y = j - pattern[k].y (); - if (x >= 0 && x < width && y >= 0 && y < height) - { - if (min == -1 || in[y][x] < min) min = in[y][x]; - if (in[y][x] > max) max = in[y][x]; - } - } - out[j * width + i] = max - min; - } -} diff --git a/Code/FBSD/ImageTools/strucel.h b/Code/FBSD/ImageTools/strucel.h deleted file mode 100755 index 0addd92195a1e69f2b9fbed58334995c3828c279..0000000000000000000000000000000000000000 --- a/Code/FBSD/ImageTools/strucel.h +++ /dev/null @@ -1,144 +0,0 @@ -#ifndef STRUCEL_H -#define STRUCEL_H - -#include "vr2i.h" - - -/** - * @class Strucel strucel.h - * \brief Structuring element for morphological operations. - */ -class Strucel -{ -public: - - /** 3x3 cross structuring element type. */ - static const int TYPE_PLUS_3X3; - /** 1x3 horizontal structuring element type. */ - static const int TYPE_HOR; - /** 3x1 vertical structuring element type. */ - static const int TYPE_VER; - - - /** - * \brief Creates a structural element. - * @param type Pattern type. - */ - Strucel (int type); - - /** - * \brief Deletes the structuring element. - */ - ~Strucel (); - - /** - * \brief Returns the pattern width. - */ - inline int getWidth () const - { - return width; - } - - /** - * \brief Returns the pattern height. - */ - inline int getHeight () const - { - return height; - } - - /** - * \brief Calculates the top hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void tophatGradient (int *out, unsigned char *in, int width, int height); - - /** - * \brief Calculates the top hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void tophatGradient (int *out, int *in, int width, int height); - - /** - * \brief Calculates the top hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image bi-dimensional array. - * @param width Image width. - * @param height Image height. - */ - void tophatGradient (int *out, int **in, int width, int height); - - /** - * \brief Calculates the black hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void blackhatGradient (int *out, unsigned char *in, int width, int height); - - /** - * \brief Calculates the black hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void blackhatGradient (int *out, int *in, int width, int height); - - /** - * \brief Calculates the black hat gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image bi-dimensional array. - * @param width Image width. - * @param height Image height. - */ - void blackhatGradient (int *out, int **in, int width, int height); - - /** - * \brief Calculates the morphological gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void morphoGradient (int *out, unsigned char *in, int width, int height); - - /** - * \brief Calculates the morphological gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image array. - * @param width Image width. - * @param height Image height. - */ - void morphoGradient (int *out, int *in, int width, int height); - - /** - * \brief Calculates the morphological gradient of an image. - * @param out Output gradient array (the memory should be allocated before). - * @param in Image bi-dimensional array. - * @param width Image width. - * @param height Image height. - */ - void morphoGradient (int *out, int **in, int width, int height); - - -private: - - /** Width of the structuring element. */ - int width; - /** Height of the structuring element. */ - int height; - /** Size of the pattern. */ - int size; - /** Pattern of the structuring element as the list of occupied pixels. */ - Vr2i *pattern; -}; - -#endif diff --git a/Code/FBSD/ImageTools/vmap.cpp b/Code/FBSD/ImageTools/vmap.cpp index 5ca9014d86b03ddcfced079cb8d78df198b59e8f..9931a60e559641e44d3912d02e5c5344b0e5d3a4 100755 --- a/Code/FBSD/ImageTools/vmap.cpp +++ b/Code/FBSD/ImageTools/vmap.cpp @@ -6,12 +6,6 @@ const int VMap::TYPE_UNKNOWN = -1; const int VMap::TYPE_SOBEL_3X3 = 0; const int VMap::TYPE_SOBEL_5X5 = 1; -const int VMap::TYPE_TOP_HAT = 2; -const int VMap::TYPE_BLACK_HAT = 3; -const int VMap::TYPE_MORPHO = 4; -const int VMap::TYPE_FULL_TOP_HAT = 5; -const int VMap::TYPE_FULL_BLACK_HAT = 6; -const int VMap::TYPE_FULL_MORPHO = 7; const int VMap::NEAR_SQ_ANGLE = 80; // 80% (roughly 25 degrees) const int VMap::DEFAULT_GRADIENT_THRESHOLD = 20; @@ -30,79 +24,7 @@ VMap::VMap (int width, int height, unsigned char *data, int type) this->gtype = type; init (); imap = new int[width * height]; - if (type == TYPE_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.tophatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.tophatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.blackhatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.blackhatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.morphoGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.morphoGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_SOBEL_5X5) + if (type == TYPE_SOBEL_5X5) { buildSobel5x5Map (data); for (int i = 0; i < width * height; i++) @@ -111,7 +33,7 @@ VMap::VMap (int width, int height, unsigned char *data, int type) } else if (type == TYPE_SOBEL_3X3) { - buildGradientMap (data); + buildSobel3x3Map (data); for (int i = 0; i < width * height; i++) imap[i] = (int) sqrt (map[i].norm2 ()); gmagThreshold *= gradientThreshold; @@ -126,79 +48,7 @@ VMap::VMap (int width, int height, int *data, int type) this->gtype = type; init (); imap = new int[width * height]; - if (type == TYPE_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.tophatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.tophatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.blackhatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.blackhatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.morphoGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.morphoGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_SOBEL_5X5) + if (type == TYPE_SOBEL_5X5) { buildSobel5x5Map (data); for (int i = 0; i < width * height; i++) @@ -207,7 +57,7 @@ VMap::VMap (int width, int height, int *data, int type) } else if (type == TYPE_SOBEL_3X3) { - buildGradientMap (data); + buildSobel3x3Map (data); for (int i = 0; i < width * height; i++) imap[i] = (int) sqrt (map[i].norm2 ()); gmagThreshold *= gradientThreshold; @@ -222,79 +72,7 @@ VMap::VMap (int width, int height, int **data, int type) this->gtype = type; init (); imap = new int[width * height]; - if (type == TYPE_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_TOP_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.tophatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.tophatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.tophatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_BLACK_HAT) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.blackhatGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.blackhatGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.blackhatGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - buildSobel5x5Map (data); - } - else if (type == TYPE_FULL_MORPHO) - { - Strucel se (Strucel::TYPE_PLUS_3X3); - se.morphoGradient (imap, data, width, height); - int *jmap = new int[width * height]; - Strucel seh (Strucel::TYPE_HOR); - seh.morphoGradient (jmap, data, width, height); - int *kmap = new int[width * height]; - Strucel sev (Strucel::TYPE_VER); - sev.morphoGradient (kmap, data, width, height); - map = new Vr2i[width * height]; - Vr2i *tmpmap = map; - for (int i = 0; i < width * height; i ++) - { - tmpmap->set (jmap[i], kmap[i]); - tmpmap ++; - } - } - else if (type == TYPE_SOBEL_5X5) + if (type == TYPE_SOBEL_5X5) { buildSobel5x5Map (data); for (int i = 0; i < width * height; i++) @@ -303,7 +81,7 @@ VMap::VMap (int width, int height, int **data, int type) } else if (type == TYPE_SOBEL_3X3) { - buildGradientMap (data); + buildSobel3x3Map (data); for (int i = 0; i < width * height; i++) imap[i] = (int) sqrt (map[i].norm2 ()); gmagThreshold *= gradientThreshold; @@ -376,7 +154,7 @@ void VMap::init () } -void VMap::buildGradientMap (unsigned char *data) +void VMap::buildSobel3x3Map (unsigned char *data) { map = new Vr2i[width * height]; Vr2i *gm = map; @@ -417,7 +195,7 @@ void VMap::buildGradientMap (unsigned char *data) } -void VMap::buildGradientMap (int *data) +void VMap::buildSobel3x3Map (int *data) { map = new Vr2i[width * height]; Vr2i *gm = map; @@ -458,7 +236,7 @@ void VMap::buildGradientMap (int *data) } -void VMap::buildGradientMap (int **data) +void VMap::buildSobel3x3Map (int **data) { map = new Vr2i[width * height]; Vr2i *gm = map; diff --git a/Code/FBSD/ImageTools/vmap.h b/Code/FBSD/ImageTools/vmap.h index 21224e40a9ed46b1b369dc35b40e9c3fb19994e0..dab6be315cda9838500c467458bcff7c03358913 100755 --- a/Code/FBSD/ImageTools/vmap.h +++ b/Code/FBSD/ImageTools/vmap.h @@ -2,7 +2,6 @@ #define VMAP_H #include "pt2i.h" -#include "strucel.h" /** @@ -19,18 +18,6 @@ public: static const int TYPE_SOBEL_3X3; /** Gradient extraction method : Sobel with 5x5 kernel. */ static const int TYPE_SOBEL_5X5; - /** Gradient extraction method : Morphological top hat (I - E(I)). */ - static const int TYPE_TOP_HAT; - /** Gradient extraction method : Morphological black hat (D(I) - I). */ - static const int TYPE_BLACK_HAT; - /** Gradient extraction method : Morphological gradient (D(I) - E(I)). */ - static const int TYPE_MORPHO; - /** Gradient extraction method : Morphological directional top hat. */ - static const int TYPE_FULL_TOP_HAT; - /** Gradient extraction method : Morphological directional black hat. */ - static const int TYPE_FULL_BLACK_HAT; - /** Gradient extraction method : Morphological directional gradient. */ - static const int TYPE_FULL_MORPHO; /** @@ -266,7 +253,7 @@ public: /** * \brief Sets mask activation on or off. - * @param status Required activation status. + * @param status New activation status. */ inline void setMasking (bool status) { masking = status; } @@ -293,8 +280,6 @@ private: /** Default value for near angular deviation tests. */ static const int NEAR_SQ_ANGLE; - /** Effective value for the angular deviation test. */ - int angleThreshold; /** Default threshold value for the gradient selection. */ static const int DEFAULT_GRADIENT_THRESHOLD; /** Default threshold value for the gradient resolution (filtering). */ @@ -314,9 +299,20 @@ private: int gtype; /** Vector map. */ Vr2i *map; - /** Magnitude map (squarred norm or morphologicalgradient). */ + /** Magnitude map (squared norm). */ int *imap; + /** Effective value for the angular deviation test. */ + int angleThreshold; + /** Standardized gradient threshold for highest value detection. */ + int gradientThreshold; + /** Gradient magnitude threshold for highest value detection. */ + int gmagThreshold; + /** Gradient resolution threshold for local max filtering. */ + int gradres; + /** Direction constraint status for local gradient maxima. */ + bool orientedGradient; + /** Occupancy mask. */ bool *mask; /** Flag indicating whether the occupancy mask is in use. */ @@ -327,14 +323,6 @@ private: int *dilations; /** Dilation bowl. */ Vr2i *bowl; - /** Standardized gradient threshold for highest value detection. */ - int gradientThreshold; - /** Gradient magnitude threshold for highest value detection. */ - int gmagThreshold; - /** Gradient resolution threshold for local max filtering. */ - int gradres; - /** Direction constraint for local gradient maxima. */ - bool orientedGradient; /** @@ -347,21 +335,21 @@ private: * Uses a Sobel 3x3 kernel by default. * @param data Initial scalar data. */ - void buildGradientMap (unsigned char *data); + void buildSobel3x3Map (unsigned char *data); /** * \brief Builds the vector map as a gradient map from provided data. * Uses a Sobel 3x3 kernel by default. * @param data Initial scalar data. */ - void buildGradientMap (int *data); + void buildSobel3x3Map (int *data); /** * \brief Builds the vector map as a gradient map from provided data. * Uses a Sobel 3x3 kernel by default. * @param data Initial bi-dimensional scalar data. */ - void buildGradientMap (int **data); + void buildSobel3x3Map (int **data); /** * \brief Builds the vector map as a gradient map from provided data. @@ -400,6 +388,6 @@ private: * @param val Input values. */ void sortMax (int *lmax, int n, int *val) const; -}; +}; #endif diff --git a/Code/FBSD/main.cpp b/Code/FBSD/main.cpp index 72ecb643587beb041154e7f40ca4a84b71662298..839c7bfe3f679d7de293fbc23813d7386cf53226 100755 --- a/Code/FBSD/main.cpp +++ b/Code/FBSD/main.cpp @@ -67,18 +67,6 @@ int main (int argc, char *argv[]) window.useGradient (VMap::TYPE_SOBEL_3X3); else if (string(argv[i]) == string ("-sobel5x5")) window.useGradient (VMap::TYPE_SOBEL_5X5); - else if (string(argv[i]) == string ("-tophat")) - window.useGradient (VMap::TYPE_TOP_HAT); - else if (string(argv[i]) == string ("-blackhat")) - window.useGradient (VMap::TYPE_BLACK_HAT); - else if (string(argv[i]) == string ("-morpho")) - window.useGradient (VMap::TYPE_MORPHO); - else if (string(argv[i]) == string ("-fulltophat")) - window.useGradient (VMap::TYPE_FULL_TOP_HAT); - else if (string(argv[i]) == string ("-fullblackhat")) - window.useGradient (VMap::TYPE_FULL_BLACK_HAT); - else if (string(argv[i]) == string ("-fullmorpho")) - window.useGradient (VMap::TYPE_FULL_MORPHO); // DEV IN else {