00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <iostream>
00026 #include <qvipp.h>
00027 #include <QVMatrix>
00028 #include <qvipp/macros.h>
00029
00030
00031 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSharpen, uChar, 1, _8u_C1R);
00032 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSharpen, sFloat, 1, _32f_C1R);
00033
00034
00035 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, uChar, 1, _8u_C1R);
00036 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, sShort, 1, _16s_C1R);
00037 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, sFloat, 1, _32f_C1R);
00038
00039 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, uChar, 3, _8u_C3R);
00040 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, sShort, 3, _16s_C3R);
00041 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelVert, sFloat, 3, _32f_C3R);
00042
00043 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, uChar, 1, _8u_C1R);
00044 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, sShort, 1, _16s_C1R);
00045 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, sFloat, 1, _32f_C1R);
00046
00047 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, uChar, 3, _8u_C3R);
00048 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, sShort, 3, _16s_C3R);
00049 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(FilterSobelHoriz, sFloat, 3, _32f_C3R);
00050
00051
00052 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, uChar, 1, _8u_C1R);
00053 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, uShort, 1, _16u_C1R);
00054 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, sFloat, 1, _32f_C1R);
00055
00056 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, uChar, 3, _8u_C3R);
00057 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, uShort, 3, _16u_C3R);
00058 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Erode3x3, sFloat, 3, _32f_C3R);
00059
00060
00061 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, uChar, 1, _8u_C1R);
00062 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, uShort, 1, _16u_C1R);
00063 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, sFloat, 1, _32f_C1R);
00064
00065 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, uChar, 3, _8u_C3R);
00066 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, uShort, 3, _16u_C3R);
00067 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_ROIOFFSET_BORDER3x3(Dilate3x3, sFloat, 3, _32f_C3R);
00068
00069 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_DESTIMAGE_Ti_Cj_ROIOFFSET(Copy, uChar, 3, _8u_P3C3R);
00070 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_DESTIMAGE_Ti_Cj_ROIOFFSET(Copy, uShort, 3, _16u_P3C3R);
00071 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_DESTIMAGE_Ti_Cj_ROIOFFSET(Copy, sShort, 3, _16s_P3C3R);
00072 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_DESTIMAGE_Ti_Cj_ROIOFFSET(Copy, sInt, 3, _32s_P3C3R);
00073 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_SRCIMAGE_Ti_C1_DESTIMAGE_Ti_Cj_ROIOFFSET(Copy, sFloat, 3, _32f_P3C3R);
00074 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_ROIOFFSET(Copy, uChar, 3, _8u_C3P3R);
00075 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_ROIOFFSET(Copy, uShort, 3, _16u_C3P3R);
00076 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_ROIOFFSET(Copy, sShort, 3, _16s_C3P3R);
00077 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_ROIOFFSET(Copy, sInt, 3, _32s_C3P3R);
00078 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_DESTIMAGE_Ti_C1_ROIOFFSET(Copy, sFloat, 3, _32f_C3P3R);
00079 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Ck_CHANNELNUM_ROIOFFSET(Copy, uChar, 3, 1, _8u_C3C1R);
00080 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Ck_CHANNELNUM_ROIOFFSET(Copy, uShort, 3, 1, _16u_C3C1R);
00081 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Ck_CHANNELNUM_ROIOFFSET(Copy, sShort, 3, 1, _16s_C3C1R);
00082 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Ck_CHANNELNUM_ROIOFFSET(Copy, sInt, 3, 1, _32s_C3C1R);
00083 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Ck_CHANNELNUM_ROIOFFSET(Copy, sFloat, 3, 1, _32f_C3C1R);
00084 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_SRCIMAGE_Ti_Cj_DESTIMAGE_C1_Tuchar_IPPCMPOP_ROIOFFSET(Compare, uChar, 3, _8u_C3R);
00085 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_SRCIMAGE_Ti_Cj_DESTIMAGE_C1_Tuchar_IPPCMPOP_ROIOFFSET(Compare, uShort, 3, _16u_C3R);
00086 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_SRCIMAGE_Ti_Cj_DESTIMAGE_C1_Tuchar_IPPCMPOP_ROIOFFSET(Compare, sShort, 3, _16s_C3R);
00087 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_SRCIMAGE_Ti_Cj_DESTIMAGE_C1_Tuchar_IPPCMPOP_ROIOFFSET(Compare, sFloat, 3, _32f_C3R);
00088 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_BUFFERIMAGE_Ti_Cj_IPPMASKSIZE__ROIOFFSET(FilterSobelNegVertBorder, uChar, sShort, 1, _8u16s_C1R);
00089 DEFINE_IPP_FUNCTION_SRCIMAGE_Ti_Cj_DESTIMAGE_Ti_Cj_BUFFERIMAGE_Ti_Cj_IPPMASKSIZE__ROIOFFSET(FilterSobelHorizBorder, uChar, sShort, 1, _8u16s_C1R);
00090 DEFINE_IPP_FUNCTION_SRCGENERICIMAGE_DESTBUFFERIMAGE_Ti_Cj_IPPMASKSIZE__ROIOFFSET(FilterSobelNegVertGetBufferSize, uChar, sShort, 1, _8u16s_C1R);
00091 DEFINE_IPP_FUNCTION_SRCGENERICIMAGE_DESTBUFFERIMAGE_Ti_Cj_IPPMASKSIZE__ROIOFFSET(FilterSobelHorizGetBufferSize, uChar, sShort, 1, _8u16s_C1R);
00092
00093
00094
00095 #define DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_DOUBLE_DOUBLE_INTERPOLATION(NAME, TYPE, PLANES, SUBFIX) \
00096 void NAME(const QVImage<TYPE, PLANES> &src, QVImage<TYPE, PLANES> &dest, int interpolation) \
00097 { \
00098 double factorX = (double) dest.getROI().width() / (double) src.getROI().width(), \
00099 factorY = (double) dest.getROI().height() / (double) src.getROI().height(); \
00100 \
00101 IPP_DEBUG(NAME, ippi ## NAME ## SUBFIX, \
00102 src.getReadData(), IMAGE_SIZE(src), src.getStep(), IMAGE_ROIRECT(src), \
00103 PDATA_WRITE(dest), dest.getStep(), IMAGE_ROISIZE(dest), \
00104 factorX, factorY, interpolation); \
00105 }
00106
00107 DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_DOUBLE_DOUBLE_INTERPOLATION(Resize, uChar, 1, _8u_C1R);
00108 DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_DOUBLE_DOUBLE_INTERPOLATION(Resize, uChar, 3, _8u_C3R);
00109 DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_DOUBLE_DOUBLE_INTERPOLATION(Resize, uShort, 1, _16u_C1R);
00110 DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_DOUBLE_DOUBLE_INTERPOLATION(Resize, sFloat, 1, _32f_C1R);
00111
00112 #define DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_BUFFER_KERNELSIZE_SFLOAT_BORDERTYPE_BORDERVALUE(NAME, TYPE, C, SUBFIX) \
00113 void NAME(const QVImage<TYPE, C> &src, QVImage<TYPE, C> &dest, QVImage<uChar> &buffer, sInt kernelSize, \
00114 sFloat sfloat, IppiBorderType borderType, sFloat borderValue, const QPoint &destROIOffset) \
00115 { \
00116 dest.setROI(destROIOffset.x(), destROIOffset.y(), \
00117 src.getROI().width(), src.getROI().height()); \
00118 \
00119 IPP_DEBUG(NAME, ippi ## NAME ## SUBFIX, \
00120 PDATA_READ(src), src.getStep(), \
00121 PDATA_WRITE(dest), dest.getStep(), \
00122 IMAGE_ROISIZE(dest), \
00123 kernelSize, sfloat, borderType, borderValue, \
00124 buffer.getWriteData()); \
00125 }
00126
00127 DEFINE_IPP_FUNCTION_QVIMAGE_QVIMAGE_BUFFER_KERNELSIZE_SFLOAT_BORDERTYPE_BORDERVALUE(FilterGaussBorder, sFloat, 1, _32f_C1R);
00128
00129 #define DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_THRESHOLD_PIPPIPOINT_UINT_PUINT_IPPINORM_BORDER(NAME, TYPE, C, SUBFIX) \
00130 void NAME(const QVImage<TYPE, C> &img, QVImage<uChar> &buffer, QList<QPoint> &points, TYPE threshold, IppiNorm norm, uInt border, uInt maxPeakCount) \
00131 { \
00132 int pPeakCount; \
00133 IppiPoint *pPeak = new IppiPoint[maxPeakCount](); \
00134 \
00135 IPP_DEBUG(NAME, ippi ## NAME ## SUBFIX, \
00136 PDATA_READ(img), img.getStep(), IMAGE_ROISIZE(img), \
00137 threshold, pPeak, maxPeakCount, &pPeakCount, \
00138 norm, border, buffer.getWriteData()); \
00139 \
00140 for (int n = 0; n < pPeakCount; n++) \
00141 points.append(QPoint(pPeak[n].x, pPeak[n].y)); \
00142 \
00143 delete pPeak; \
00144 }
00145
00146 DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_THRESHOLD_PIPPIPOINT_UINT_PUINT_IPPINORM_BORDER(FindPeaks3x3, sInt, 1, _32s_C1R);
00147 DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_THRESHOLD_PIPPIPOINT_UINT_PUINT_IPPINORM_BORDER(FindPeaks3x3, sFloat, 1, _32f_C1R);
00148
00149 #define DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_ROIWIDTH(NAME, TYPE, C, SUBFIX) \
00150 void NAME(const QVImage<TYPE,C> &image, QVImage<uChar> &buffer) \
00151 { \
00152 int pBufferSize; \
00153 \
00154 IPP_DEBUG(Peaks3x3GetBufferSize, ippi ## NAME ## SUBFIX, \
00155 image.getROI().width(), &pBufferSize); \
00156 buffer = QVImage<uChar>(2*pBufferSize,1); \
00157 }
00158
00159 DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_ROIWIDTH(FindPeaks3x3GetBufferSize, sInt, 1, _32s_C1R);
00160 DEFINE_IPP_FUNCTION_QVIMAGE_BUFFER_ROIWIDTH(FindPeaks3x3GetBufferSize, sFloat, 1, _32f_C1R);
00161
00163 void YUV420ToRGB(const QVImage<uChar, 1> &src1, const QVImage<uChar, 1> &src2, const QVImage<uChar, 1> &src3,
00164 QVImage<uChar, 3> &dest, const QPoint &destROIOffset)
00165 {
00166 const uChar * pSrc[3] = { PDATA_READ(src1), PDATA_READ(src2), PDATA_READ(src3) };
00167 int srcStep[3] = { src1.getStep(), src2.getStep(), src3.getStep() };
00168
00169 dest.setROI(destROIOffset.x(), destROIOffset.y(), src1.getROI().width(), src1.getROI().height());
00170
00171 IPP_DEBUG("YUV420ToRGB", ippiYUV420ToRGB_8u_P3C3R,
00172 pSrc, srcStep,
00173 PDATA_WRITE(dest), dest.getStep(),
00174 IMAGE_ROISIZE(dest));
00175 }
00176
00178 void RGBToYUV420(const QVImage<uChar, 3> &src, QVImage<uChar, 1> &dst1, QVImage<uChar, 1> &dst2, QVImage<uChar, 1> &dst3, const QPoint &destROIOffset)
00179 {
00180 uChar * pDst[3] = { PDATA_WRITE(dst1), PDATA_WRITE(dst2), PDATA_WRITE(dst3) };
00181 int dstStep[3] = { dst1.getStep(), dst2.getStep(), dst3.getStep() };
00182
00183 dst1.setROI(destROIOffset.x(), destROIOffset.y(), src.getROI().width(), src.getROI().height());
00184 dst2.setROI(destROIOffset.x()/2, destROIOffset.y()/2, src.getROI().width()/2, src.getROI().height()/2);
00185 dst3.setROI(destROIOffset.x()/2, destROIOffset.y()/2, src.getROI().width()/2, src.getROI().height()/2);
00186
00187 IPP_DEBUG("RGBToTUV420", ippiRGBToYUV420_8u_C3P3R,
00188 PDATA_READ(src), src.getStep(),
00189 pDst, dstStep,
00190 IMAGE_ROISIZE(dst1));
00191 }
00192
00193 void FilterGaussGetBufferSize(const QVGenericImage &image, QVImage<uChar> &buffer, uInt kernelSize)
00194 {
00195 int pBufferSize;
00196 IPP_DEBUG(FilterGaussGetBufferSize, ippiFilterGaussGetBufferSize_32f_C1R, IMAGE_ROISIZE(image), kernelSize, &pBufferSize);
00197 buffer = QVImage<uChar>(pBufferSize,1);
00198 }
00199
00200 void MinEigenValGetBufferSize(const QVGenericImage &image, QVImage<uChar> &buffer, uInt apertureSize, uInt avgWindow)
00201 {
00202 int pBufferSize;
00203 IPP_DEBUG(MinEigenVal, ippiMinEigenValGetBufferSize_8u32f_C1R, IMAGE_ROISIZE(image), apertureSize, avgWindow, &pBufferSize);
00204 buffer = QVImage<uChar>(pBufferSize,1);
00205 }
00206
00207 void CannyGetSize(const QVGenericImage &src, QVImage<uChar> &buffer)
00208 {
00209 int cannyBufferSize;
00210 IPP_DEBUG(CannyGetSize, ippiCannyGetSize, IMAGE_ROISIZE(src),&cannyBufferSize);
00211 buffer = QVImage<uChar>(cannyBufferSize,1);
00212 }
00213
00214 void FastMarchingGetBufferSize(const QVGenericImage &image, QVImage<uChar> &buffer)
00215 {
00216 int bufferSize;
00217 IPP_DEBUG(CannyGetSize, ippiFastMarchingGetBufferSize_8u32f_C1R, IMAGE_ROISIZE(image),&bufferSize);
00218 buffer = QVImage<uChar>(bufferSize,1);
00219 }
00220
00221
00222 void InpaintInitAllocC3(IppiInpaintState_8u_C3R **pState, const QVImage<sFloat> &distances, const QVImage<uChar> &mask,
00223 const sFloat radius, const IppiInpaintFlag flag)
00224 {
00225 IPP_DEBUG( Inpaint, ippiInpaintInitAlloc_8u_C3R, pState, distances.getReadData(), distances.getStep(),
00226 mask.getReadData(), mask.getStep(), IMAGE_ROISIZE(mask), radius, flag);
00227 }
00228
00229 void InpaintFreeC3(IppiInpaintState_8u_C3R *pState)
00230 {
00231 IPP_DEBUG(Inpaint, ippiInpaintFree_8u_C3R,pState);
00232 }
00233
00234 void InpaintInitAllocC1(IppiInpaintState_8u_C1R **pState, const QVImage<sFloat> &distances, const QVImage<uChar> &mask,
00235 const sFloat radius, const IppiInpaintFlag flag)
00236 {
00237 IPP_DEBUG( Inpaint, ippiInpaintInitAlloc_8u_C1R, pState, distances.getReadData(), distances.getStep(),
00238 mask.getReadData(), mask.getStep(), IMAGE_ROISIZE(mask), radius, flag);
00239 }
00240
00241 void InpaintFreeC1(IppiInpaintState_8u_C1R *pState)
00242 {
00243 IPP_DEBUG(Inpaint, ippiInpaintFree_8u_C1R,pState);
00244 }
00245
00246
00247 QVector<int> HistogramRange(const QVImage<uChar, 1> &src)
00248 {
00249
00250 int nLevels = 257;
00251 sInt pLevels[nLevels];
00252 int pHist[nLevels];
00253
00254 for(sInt i=0; i<nLevels; i++)
00255 pLevels[i] = i;
00256
00257 IPP_DEBUG(HistogramRange, ippiHistogramRange_8u_C1R,
00258 PDATA_READ(src), src.getStep(), IMAGE_ROISIZE(src),
00259 pHist, pLevels, nLevels);
00260
00262
00263 QVector< int > result(256);
00264 for (int i=0; i<result.size(); i++)
00265 result[i] = pHist[i];
00266
00267 return result;
00268 }
00269
00270 QMap<sInt, int> HistogramRange(const QVImage<uChar, 1> &src, QList<uChar> values)
00271 {
00272
00273 int nLevels = values.size();
00274 sInt pLevels[nLevels];
00275 int pHist[nLevels];
00276
00277 Q_ASSERT_X(false, "QMap<sInt, int> HistogramRange(QVImage<uChar, 1> &src, QList<uChar> values)",
00278 "Tried an user defined values QList. Functionality not implemented yet.");
00279
00280 IPP_DEBUG(HistogramRange, ippiHistogramRange_8u_C1R,
00281 PDATA_READ(src), src.getStep(), IMAGE_ROISIZE(src),
00282 pHist, pLevels, nLevels);
00283
00285
00286 QMap<sInt, int> histogram;
00287 for (int i=0; i<nLevels; i++)
00288 histogram.insert(pLevels[i], pHist[i]);
00289
00290 return histogram;
00291 }
00292
00293
00294 void FloodFillGetSize(const QVGenericImage &src, QVImage<uChar> &buffer)
00295 {
00296 int floodFillBufferSize;
00297 IPP_DEBUG(FloodFillGetSize, ippiFloodFillGetSize, IMAGE_ROISIZE(src),&floodFillBufferSize);
00298 buffer = QVImage<uChar>(floodFillBufferSize,1);
00299 }
00300
00301 #define CREATE_IPP_FUNCTION_FLOOD_FILL(NAME, CONNECTIVITY, SUBFIX, TYPE) \
00302 void NAME(QVImage<TYPE> &img, QVImage<uChar> &buffer, \
00303 uInt seedX, uInt seedY, TYPE newVal, TYPE minDelta, TYPE maxDelta) \
00304 { \
00305 IppiConnectedComp pRegion; \
00306 IPP_DEBUG(NAME, ippiFloodFill ## CONNECTIVITY ## SUBFIX, \
00307 PDATA_WRITE(img), img.getStep(), IMAGE_ROISIZE(img), \
00308 IPP_POINT(seedX, seedY), newVal, minDelta, maxDelta, \
00309 &pRegion, buffer.getWriteData()); \
00310 }
00311
00312 CREATE_IPP_FUNCTION_FLOOD_FILL(FloodFillRange4Connected, _Range4Con, _8u_C1IR, uChar);
00313 CREATE_IPP_FUNCTION_FLOOD_FILL(FloodFillGradient4Connected, _Grad4Con, _8u_C1IR, uChar);
00314
00315 #define CREATE_IPP_FUNCTION_WARP_PERSPECTIVE(NAME, SUBFIX, C, TYPE) \
00316 void NAME(const QVImage<TYPE, C> &src, QVImage<TYPE, C> &dest, const QVMatrix &rectifyingHomography, int interpolation, const QPoint &) \
00317 { \
00318 double coeffs[3][3]; \
00319 for (int i = 0; i < 3; i++) \
00320 for (int j = 0; j < 3; j++) \
00321 coeffs[i][j] = rectifyingHomography(i,j); \
00322 \
00323 IPP_DEBUG(NAME, ippi ## NAME ## SUBFIX, \
00324 src.getReadData(), IMAGE_SIZE(src), src.getStep(), IMAGE_ROIRECT(src), \
00325 PDATA_WRITE(dest), dest.getStep(), IMAGE_ROIRECT(dest), \
00326 coeffs, interpolation); \
00327 }
00328
00329 CREATE_IPP_FUNCTION_WARP_PERSPECTIVE(WarpPerspective, _8u_C1R, 1, uChar);
00330 CREATE_IPP_FUNCTION_WARP_PERSPECTIVE(WarpPerspective, _8u_C3R, 3, uChar);
00331
00332 #include <qvmath/qvmatrix.h>
00333 void Filter(const QVImage<sFloat> &src, QVImage<sFloat> &dest, const QVMatrix kernel, const QPoint &destROIOffset)
00334 {
00335 Q_ASSERT(kernel.getCols() == kernel.getRows());
00336
00337 const int kernelSize = kernel.getCols();
00338 sFloat kernelValues[kernelSize*kernelSize];
00339 for(int i = 0; i < kernelSize; i++)
00340 for(int j = 0; j < kernelSize; j++)
00341 kernelValues[i+ kernelSize*j] = kernel(i,j);
00342
00343 dest.setROI(destROIOffset.x(), destROIOffset.y(),
00344 src.getROI().width()-kernelSize+1, src.getROI().height()-kernelSize+1);
00345
00348 IPP_DEBUG(NAME, ippiFilter_32f_C1R,
00349 PDATA_READ(src), src.getStep(),
00350 PDATA_WRITE(dest), dest.getStep(),
00351 IMAGE_ROISIZE(dest),
00352 kernelValues, IPP_SIZE(kernelSize, kernelSize), IPP_POINT(0,0)
00353 );
00354 }
00355
00357 void FilterColumn(const QVImage<sFloat> &src, QVImage<sFloat> &dest, const QVVector kernel, const QPoint &destROIOffset)
00358 {
00359 const int kernelSize = kernel.size();
00360 sFloat kernelValues[kernelSize];
00361 for(int i = 0; i < kernelSize; i++)
00362 kernelValues[i] = kernel[i];
00363
00364 dest.setROI(destROIOffset.x(), destROIOffset.y(),
00365 src.getROI().width(), src.getROI().height()-kernelSize+1);
00366
00367 IPP_DEBUG(NAME, ippiFilterColumn_32f_C1R,
00368 PDATA_READ(src), src.getStep(),
00369 PDATA_WRITE(dest), dest.getStep(),
00370 IMAGE_ROISIZE(dest),
00371 kernelValues, kernelSize, kernelSize-1
00372 );
00373 }
00374
00376 void FilterRow(const QVImage<sFloat> &src, QVImage<sFloat> &dest, const QVVector kernel, const QPoint &destROIOffset)
00377 {
00378 const int kernelSize = kernel.size();
00379
00380 sFloat kernelValues[kernelSize];
00381 for(int i = 0; i < kernelSize; i++)
00382 kernelValues[i] = kernel[i];
00383
00384 dest.setROI(destROIOffset.x(), destROIOffset.y(),
00385 src.getROI().width()-kernelSize+1, src.getROI().height());
00386
00387 IPP_DEBUG(NAME, ippiFilterRow_32f_C1R,
00388 PDATA_READ(src), src.getStep(),
00389 PDATA_WRITE(dest), dest.getStep(),
00390 IMAGE_ROISIZE(dest),
00391 kernelValues, kernelSize, kernelSize-1
00392 );
00393 }