PARP Research Group University of Murcia, Spain


src/qvworkers/qvmserdetector.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008, 2009. 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 <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): QVWorker(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         // 0. Read parameters
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         // 1. Apply MSER
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         // 2. Publish resulting MSER's
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



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