00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVFILTERSELECTOR_H
00026 #define QVFILTERSELECTOR_H
00027
00028 #include <qvipp.h>
00029 #include <qvdta.h>
00030 #include <qvip.h>
00031
00032 #include <QVImage>
00033 #include <QVWorker>
00034
00035 #include <QVIndexedStringList>
00036
00038 #ifndef DOXYGEN_IGNORE_THIS
00039 template <typename T, int C> class QVFilterSelectorWorker: public QVWorker
00040 {
00041 private:
00042 QVIndexedStringList firstFilter;
00043
00045
00046 QVImage<T,1> cannyIterate(QVImage<T,1> image, double threLow, double threHigh)
00047 {
00049
00050 uInt cols = image.getCols(), rows = image.getRows();
00051 QVImage<sFloat> imageFloat(cols, rows), dX(cols, rows), dY(cols, rows), dXNeg(cols, rows);
00052 QVImage<uChar> canny(cols, rows), buffer;
00053
00055
00056 Convert(image, imageFloat);
00057
00059
00060 FilterSobelHorizMask(imageFloat, dY, ippMskSize3x3);
00061 FilterSobelVertMask(imageFloat, dX, ippMskSize3x3);
00062 MulC(dX, -1, dXNeg);
00063
00065
00066 CannyGetSize(canny, buffer);
00067 Canny(dXNeg, dY, canny, threLow, threHigh, buffer);
00068
00070
00071 return canny;
00072 }
00073
00074
00076
00077 QVImage<T,1> applyFilter(QVImage<T,1> image, int choice, double threLow, double threHigh, bool sizeOf5, int maskRow, int maskCol)
00078 {
00079 switch (choice)
00080 {
00081 case 0:
00082 {
00083 break;
00084 }
00085 case 1:
00086 {
00087 image = cannyIterate(image, threLow, threHigh);
00088 break;
00089 }
00090 case 2:
00091 {
00092 QVImage<sFloat, 1> auxImage(image);
00093 FilterHessianCornerResponseImage(image, auxImage);
00094 Ln(auxImage, auxImage);
00095 FilterEqualizeHistogram(auxImage, image);
00096 break;
00097 }
00098 case 3:
00099 {
00100 QVImage<sFloat, 1> auxImage(image);
00101 FilterHarrisCornerResponseImage(image, auxImage);
00102 Ln(auxImage, auxImage);
00103 FilterEqualizeHistogram(auxImage, image);
00104 break;
00105 }
00106 case 4:
00107 {
00108 QVImage<sFloat, 1> auxImage(image);
00109 FilterDoG(image, auxImage);
00110 Ln(auxImage, auxImage);
00111 FilterEqualizeHistogram(auxImage, image);
00112 break;
00113 }
00114 case 5:
00115 {
00116 QVImage<sFloat, 1> auxImage(image);
00117 if (sizeOf5)
00118 FilterGauss(image, auxImage, ippMskSize5x5);
00119 else
00120 FilterGauss(image, auxImage, ippMskSize3x3);
00121 return auxImage;
00122 break;
00123 }
00124 case 6:
00125 {
00126 QVImage<sFloat, 1> auxImage(image);
00127 FilterSharpen(image, auxImage);
00128 return auxImage;
00129 break;
00130 }
00131 case 7:
00132 {
00133 QVImage<sFloat, 1> auxImage(image);
00134 FilterBox(image, auxImage, QSize(maskRow, maskCol));
00135 return auxImage;
00136 break;
00137 }
00138 }
00139 return image;
00140 }
00141
00142 public:
00143 QVFilterSelectorWorker(QString name): QVWorker(name)
00144 {
00146
00147 firstFilter.append("None");
00148 firstFilter.append("Canny");
00149 firstFilter.append("Hessian");
00150 firstFilter.append("Harris");
00151 firstFilter.append("DOG");
00152 firstFilter.append("Gauss");
00153 firstFilter.append("Sharpen");
00154 firstFilter.append("Box");
00155 addProperty< QVIndexedStringList >("Filter", inputFlag, firstFilter);
00156
00158
00159 addProperty<bool>("Mask: Size of 5 (gauss)", inputFlag, false);
00160 addProperty<int>("Mask: Row (Box)", inputFlag, 3, "Row Mask Size", 1, 10);
00161 addProperty<int>("Mask: Col (Box)", inputFlag, 3, "Col Mask Size", 1, 10);
00162
00163 addProperty<double>("Threshold high (canny)", inputFlag, 150, "High threshold for Canny operator", 50, 1000);
00164 addProperty<double>("Threshold low (canny)", inputFlag, 50, "Low threshold for Canny operator", 10, 500);
00165
00166
00167 addProperty< QVImage<T,C> >("Input image", inputFlag|outputFlag);
00168 addProperty< QVImage<T,C> >("Output image", outputFlag);
00169 }
00170
00171 void iterate()
00172 {
00173 QVImage<T,1> image = getPropertyValue< QVImage<uChar,C> >("Input image");
00174
00176
00177 const QVIndexedStringList auxFF = getPropertyValue<QVIndexedStringList>("Filter");
00178
00179 const double threLow = getPropertyValue<double>("Threshold low (canny)");
00180 const double threHigh = getPropertyValue<double>("Threshold high (canny)");
00181
00182 const bool sizeOf5 = getPropertyValue<bool>("Mask: Size of 5 (gauss)");
00183 const int maskRow = getPropertyValue<int>("Mask: Row (Box)");
00184 const int maskCol = getPropertyValue<int>("Mask: Col (Box)");
00185 timeFlag("Read input parameters");
00186
00188
00189 QVImage<T,C> filteredImage = applyFilter(image, auxFF.getIndex(), threLow, threHigh, sizeOf5, maskRow, maskCol);
00190 timeFlag("Apply the filter");
00191
00192 setPropertyValue< QVImage<T,C> >("Output image", filteredImage);
00193 timeFlag("Write input parameters");
00194 }
00195 };
00196 #endif
00197 #endif