PARP Research Group University of Murcia, Spain


src/qvworkers/qvmserdetector.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
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         // 0. Read parameters
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         // 1. Apply MSER
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         // 2. Publish resulting MSER's
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



QVision framework. PARP research group, copyright 2007, 2008.