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