00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <qvdta.h>
00026 #include <qvip.h>
00027 #include <QVPolyline>
00028
00029 #include <QVMSER>
00030 #include <QVMSERDetector>
00031
00032 #ifndef DOXYGEN_IGNORE_THIS
00033 const QVImage<uChar> QVMSERDetector::negateImage(const QVImage<uChar> image) const
00034 {
00035 const uInt rows = image.getRows(), cols = image.getCols();
00036 QVImage<uChar> notImage(cols, rows);
00037 for (uInt col = 0; col < cols; col++)
00038 for (uInt row = 0; row < rows; row++)
00039 notImage(col, row) = 255 - image(col, row);
00040
00041 return notImage;
00042 }
00043
00044 QVMSERDetector::QVMSERDetector(QString name): QVWorker(name)
00045 {
00046 addProperty<int>("Delta", inputFlag, 10, "MSER parameter, as seen in the paper.", 1, 128);
00047 addProperty<int>("minAreaMSER", inputFlag, 10, "MSER with area lesser than this value are discarted.", 1, 100*100);
00048 addProperty<int>("maxAreaMSER", inputFlag, 10000, "MSER with area greater than this value are discarted.", 1, 1000*1000);
00049 addProperty<double>("diffAreaThreshold", inputFlag, 0.01, "Proportion of the difference in areas to be considered different", 0.0, 1.0);
00050 addProperty< QVImage<uChar,3> >("Input image", inputFlag|outputFlag);
00051 addProperty< QList<QVPolyline> >("MSER contours", outputFlag);
00052 }
00053
00054 void QVMSERDetector::iterate()
00055 {
00056
00057 const int delta = getPropertyValue<int>("Delta"),
00058 minArea = getPropertyValue<int>("minAreaMSER"),
00059 maxArea = getPropertyValue<int>("maxAreaMSER");
00060 const double diffAreaThreshold = getPropertyValue<double>("diffAreaThreshold");
00061 const QVImage<uChar> image = getPropertyValue< QVImage<uChar,3> >("Input image");
00062 const QVImage<uChar> notImage = negateImage(image);
00063
00064 timeFlag("Read parameters");
00065
00066
00067 QList<QVMSER> MSERListLow, MSERListHigh;
00068
00069 getMSER(image, MSERListLow, delta, minArea, maxArea, diffAreaThreshold);
00070 timeFlag("MSER Low");
00071
00072 getMSER(notImage, MSERListHigh, delta, minArea, maxArea, diffAreaThreshold);
00073 timeFlag("MSER High");
00074
00075
00076 QList< QVPolyline > polylineMSERList;
00077 getMSERContours(image, MSERListLow, polylineMSERList);
00078 getMSERContours(notImage, MSERListHigh, polylineMSERList);
00079
00080 setPropertyValue< QList<QVPolyline> >("MSER contours", polylineMSERList);
00081 timeFlag("Publish resulting images");
00082 }
00083
00084 #endif