1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
47 icvCalcMinEigenVal( const float* cov, int cov_step, float* dst,
48 int dst_step, CvSize size, CvMat* buffer )
51 float* buf = buffer->data.fl;
52 cov_step /= sizeof(cov[0]);
53 dst_step /= sizeof(dst[0]);
56 for( ; size.height--; cov += cov_step, dst += dst_step )
58 for( j = 0; j < size.width; j++ )
60 double a = cov[j*3]*0.5;
61 double b = cov[j*3+1];
62 double c = cov[j*3+2]*0.5;
64 buf[j + size.width] = (float)(a + c);
65 buf[j] = (float)((a - c)*(a - c) + b*b);
68 cvPow( buffer, buffer, 0.5 );
70 for( j = 0; j < size.width ; j++ )
71 dst[j] = (float)(buf[j + size.width] - buf[j]);
77 icvCalcHarris( const float* cov, int cov_step, float* dst,
78 int dst_step, CvSize size, CvMat* /*buffer*/, double k )
81 cov_step /= sizeof(cov[0]);
82 dst_step /= sizeof(dst[0]);
84 for( ; size.height--; cov += cov_step, dst += dst_step )
86 for( j = 0; j < size.width; j++ )
89 double b = cov[j*3+1];
90 double c = cov[j*3+2];
91 dst[j] = (float)(a*c - b*b - k*(a + c)*(a + c));
98 icvCalcEigenValsVecs( const float* cov, int cov_step, float* dst,
99 int dst_step, CvSize size, CvMat* buffer )
104 float* buf = buffer->data.fl;
105 cov_step /= sizeof(cov[0]);
106 dst_step /= sizeof(dst[0]);
108 for( ; size.height--; cov += cov_step, dst += dst_step )
110 for( j = 0; j < size.width; j++ )
112 double a = cov[j*3]*0.5;
113 double b = cov[j*3+1];
114 double c = cov[j*3+2]*0.5;
116 buf[j + size.width] = (float)(a + c);
117 buf[j] = (float)((a - c)*(a - c) + b*b);
121 cvPow( buffer, buffer, 0.5 );
123 for( j = 0; j < size.width; j++ )
126 double b = cov[j*3+1];
127 double c = cov[j*3+2];
129 double l1 = buf[j + size.width] + buf[j];
130 double l2 = buf[j + size.width] - buf[j];
136 if( e + fabs(y) < 1e-4 )
141 if( e + fabs(y) < 1e-4 )
143 e = 1./(e + fabs(y) + FLT_EPSILON);
148 buf[j] = (float)(x*x + y*y + DBL_EPSILON);
149 dst[6*j] = (float)l1;
150 dst[6*j + 2] = (float)x;
151 dst[6*j + 3] = (float)y;
157 if( e + fabs(y) < 1e-4 )
162 if( e + fabs(y) < 1e-4 )
164 e = 1./(e + fabs(y) + FLT_EPSILON);
169 buf[j + size.width] = (float)(x*x + y*y + DBL_EPSILON);
170 dst[6*j + 1] = (float)l2;
171 dst[6*j + 4] = (float)x;
172 dst[6*j + 5] = (float)y;
176 cvPow( buffer, buffer, -0.5 );
178 for( j = 0; j < size.width; j++ )
180 double t0 = buf[j]*dst[6*j + 2];
181 double t1 = buf[j]*dst[6*j + 3];
183 dst[6*j + 2] = (float)t0;
184 dst[6*j + 3] = (float)t1;
186 t0 = buf[j + size.width]*dst[6*j + 4];
187 t1 = buf[j + size.width]*dst[6*j + 5];
189 dst[6*j + 4] = (float)t0;
190 dst[6*j + 5] = (float)t1;
198 #define ICV_MINEIGENVAL 0
200 #define ICV_EIGENVALSVECS 2
203 icvCornerEigenValsVecs( const CvMat* src, CvMat* eigenv, int block_size,
204 int aperture_size, int op_type, double k=0. )
206 CvSepFilter dx_filter, dy_filter;
207 CvBoxFilter blur_filter;
209 CvMat *Dx = 0, *Dy = 0, *cov = 0;
212 int buf_size = 1 << 12;
214 CV_FUNCNAME( "icvCornerEigenValsVecs" );
218 int i, j, y, dst_y = 0, max_dy, delta = 0;
219 int aperture_size0 = aperture_size;
220 int temp_step = 0, d_step;
221 uchar* shifted_ptr = 0;
223 int stage = CV_START;
224 CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0;
225 CvFilterFixedIPPFunc ipp_scharr_vert = 0, ipp_scharr_horiz = 0;
226 CvSize el_size, size, stripe_size;
229 double factorx, factory;
230 bool use_ipp = false;
232 if( block_size < 3 || !(block_size & 1) )
233 CV_ERROR( CV_StsOutOfRange, "averaging window size must be an odd number >= 3" );
235 if( aperture_size < 3 && aperture_size != CV_SCHARR || !(aperture_size & 1) )
236 CV_ERROR( CV_StsOutOfRange,
237 "Derivative filter aperture size must be a positive odd number >=3 or CV_SCHARR" );
239 depth = CV_MAT_DEPTH(src->type);
240 d_depth = depth == CV_8U ? CV_16S : CV_32F;
242 size = cvGetMatSize(src);
243 aligned_width = cvAlign(size.width, 4);
245 aperture_size = aperture_size == CV_SCHARR ? 3 : aperture_size;
246 el_size = cvSize( aperture_size, aperture_size );
247 el_anchor = cvPoint( aperture_size/2, aperture_size/2 );
249 if( aperture_size <= 5 && icvFilterSobelVert_8u16s_C1R_p )
251 if( depth == CV_8U && aperture_size0 == CV_SCHARR )
253 ipp_scharr_vert = icvFilterScharrVert_8u16s_C1R_p;
254 ipp_scharr_horiz = icvFilterScharrHoriz_8u16s_C1R_p;
256 else if( depth == CV_32F && aperture_size0 == CV_SCHARR )
258 ipp_scharr_vert = icvFilterScharrVert_32f_C1R_p;
259 ipp_scharr_horiz = icvFilterScharrHoriz_32f_C1R_p;
261 else if( depth == CV_8U )
263 ipp_sobel_vert = icvFilterSobelVert_8u16s_C1R_p;
264 ipp_sobel_horiz = icvFilterSobelHoriz_8u16s_C1R_p;
266 else if( depth == CV_32F )
268 ipp_sobel_vert = icvFilterSobelVert_32f_C1R_p;
269 ipp_sobel_horiz = icvFilterSobelHoriz_32f_C1R_p;
273 if( ipp_sobel_vert && ipp_sobel_horiz ||
274 ipp_scharr_vert && ipp_scharr_horiz )
276 CV_CALL( tempsrc = icvIPPFilterInit( src, buf_size,
277 cvSize(el_size.width,el_size.height + block_size)));
278 shifted_ptr = tempsrc->data.ptr + el_anchor.y*tempsrc->step +
279 el_anchor.x*CV_ELEM_SIZE(depth);
280 temp_step = tempsrc->step ? tempsrc->step : CV_STUB_STEP;
281 max_dy = tempsrc->rows - aperture_size + 1;
286 ipp_sobel_vert = ipp_sobel_horiz = 0;
287 ipp_scharr_vert = ipp_scharr_horiz = 0;
289 CV_CALL( dx_filter.init_deriv( size.width, depth, d_depth, 1, 0, aperture_size0 ));
290 CV_CALL( dy_filter.init_deriv( size.width, depth, d_depth, 0, 1, aperture_size0 ));
291 max_dy = buf_size / src->cols;
292 max_dy = MAX( max_dy, aperture_size + block_size );
295 CV_CALL( Dx = cvCreateMat( max_dy, aligned_width, d_depth ));
296 CV_CALL( Dy = cvCreateMat( max_dy, aligned_width, d_depth ));
297 CV_CALL( cov = cvCreateMat( max_dy + block_size + 1, size.width, CV_32FC3 ));
298 CV_CALL( sqrt_buf = cvCreateMat( 2, size.width, CV_32F ));
299 Dx->cols = Dy->cols = size.width;
302 max_dy -= aperture_size - 1;
303 d_step = Dx->step ? Dx->step : CV_STUB_STEP;
305 CV_CALL(blur_filter.init(size.width, CV_32FC3, CV_32FC3, 0, cvSize(block_size,block_size)));
308 factorx = (double)(1 << (aperture_size - 1)) * block_size;
309 if( aperture_size0 == CV_SCHARR )
313 factory = factorx = 1./factorx;
317 for( y = 0; y < size.height; y += delta )
321 delta = MIN( size.height - y, max_dy );
322 if( y + delta == size.height )
323 stage = stage & CV_START ? CV_START + CV_END : CV_END;
324 dx_filter.process( src, Dx, cvRect(0,y,-1,delta), cvPoint(0,0), stage );
325 stripe_size.height = dy_filter.process( src, Dy, cvRect(0,y,-1,delta),
326 cvPoint(0,0), stage );
330 delta = icvIPPFilterNextStripe( src, tempsrc, y, el_size, el_anchor );
331 stripe_size.height = delta;
335 IPPI_CALL( ipp_sobel_vert( shifted_ptr, temp_step,
336 Dx->data.ptr, d_step, stripe_size,
337 aperture_size*10 + aperture_size ));
338 IPPI_CALL( ipp_sobel_horiz( shifted_ptr, temp_step,
339 Dy->data.ptr, d_step, stripe_size,
340 aperture_size*10 + aperture_size ));
342 else /*if( ipp_scharr_vert )*/
344 IPPI_CALL( ipp_scharr_vert( shifted_ptr, temp_step,
345 Dx->data.ptr, d_step, stripe_size ));
346 IPPI_CALL( ipp_scharr_horiz( shifted_ptr, temp_step,
347 Dy->data.ptr, d_step, stripe_size ));
351 for( i = 0; i < stripe_size.height; i++ )
353 float* cov_data = (float*)(cov->data.ptr + i*cov->step);
354 if( d_depth == CV_16S )
356 const short* dxdata = (const short*)(Dx->data.ptr + i*Dx->step);
357 const short* dydata = (const short*)(Dy->data.ptr + i*Dy->step);
359 for( j = 0; j < size.width; j++ )
361 double dx = dxdata[j]*factorx;
362 double dy = dydata[j]*factory;
364 cov_data[j*3] = (float)(dx*dx);
365 cov_data[j*3+1] = (float)(dx*dy);
366 cov_data[j*3+2] = (float)(dy*dy);
371 const float* dxdata = (const float*)(Dx->data.ptr + i*Dx->step);
372 const float* dydata = (const float*)(Dy->data.ptr + i*Dy->step);
374 for( j = 0; j < size.width; j++ )
376 double dx = dxdata[j]*factorx;
377 double dy = dydata[j]*factory;
379 cov_data[j*3] = (float)(dx*dx);
380 cov_data[j*3+1] = (float)(dx*dy);
381 cov_data[j*3+2] = (float)(dy*dy);
386 if( y + stripe_size.height >= size.height )
387 stage = stage & CV_START ? CV_START + CV_END : CV_END;
389 stripe_size.height = blur_filter.process(cov,cov,
390 cvRect(0,0,-1,stripe_size.height),cvPoint(0,0),stage+CV_ISOLATED_ROI);
392 if( op_type == ICV_MINEIGENVAL )
393 icvCalcMinEigenVal( cov->data.fl, cov->step,
394 (float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
395 stripe_size, sqrt_buf );
396 else if( op_type == ICV_HARRIS )
397 icvCalcHarris( cov->data.fl, cov->step,
398 (float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
399 stripe_size, sqrt_buf, k );
400 else if( op_type == ICV_EIGENVALSVECS )
401 icvCalcEigenValsVecs( cov->data.fl, cov->step,
402 (float*)(eigenv->data.ptr + dst_y*eigenv->step), eigenv->step,
403 stripe_size, sqrt_buf );
405 dst_y += stripe_size.height;
413 cvReleaseMat( &cov );
414 cvReleaseMat( &sqrt_buf );
415 cvReleaseMat( &tempsrc );
420 cvCornerMinEigenVal( const void* srcarr, void* eigenvarr,
421 int block_size, int aperture_size )
423 CV_FUNCNAME( "cvCornerMinEigenVal" );
427 CvMat stub, *src = (CvMat*)srcarr;
428 CvMat eigstub, *eigenv = (CvMat*)eigenvarr;
430 CV_CALL( src = cvGetMat( srcarr, &stub ));
431 CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
433 if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
434 CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
435 CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
437 if( !CV_ARE_SIZES_EQ( src, eigenv ))
438 CV_ERROR( CV_StsUnmatchedSizes, "" );
440 CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_MINEIGENVAL ));
447 cvCornerHarris( const CvArr* srcarr, CvArr* harris_responce,
448 int block_size, int aperture_size, double k )
450 CV_FUNCNAME( "cvCornerHarris" );
454 CvMat stub, *src = (CvMat*)srcarr;
455 CvMat eigstub, *eigenv = (CvMat*)harris_responce;
457 CV_CALL( src = cvGetMat( srcarr, &stub ));
458 CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
460 if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
461 CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
462 CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
464 if( !CV_ARE_SIZES_EQ( src, eigenv ))
465 CV_ERROR( CV_StsUnmatchedSizes, "" );
467 CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_HARRIS, k ));
474 cvCornerEigenValsAndVecs( const void* srcarr, void* eigenvarr,
475 int block_size, int aperture_size )
477 CV_FUNCNAME( "cvCornerEigenValsAndVecs" );
481 CvMat stub, *src = (CvMat*)srcarr;
482 CvMat eigstub, *eigenv = (CvMat*)eigenvarr;
484 CV_CALL( src = cvGetMat( srcarr, &stub ));
485 CV_CALL( eigenv = cvGetMat( eigenv, &eigstub ));
487 if( CV_MAT_CN(eigenv->type)*eigenv->cols != src->cols*6 ||
488 eigenv->rows != src->rows )
489 CV_ERROR( CV_StsUnmatchedSizes, "Output array should be 6 times "
490 "wider than the input array and they should have the same height");
492 if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
493 CV_MAT_TYPE(eigenv->type) != CV_32FC1 )
494 CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
496 CV_CALL( icvCornerEigenValsVecs( src, eigenv, block_size, aperture_size, ICV_EIGENVALSVECS ));
503 cvPreCornerDetect( const void* srcarr, void* dstarr, int aperture_size )
505 CvSepFilter dx_filter, dy_filter, d2x_filter, d2y_filter, dxy_filter;
506 CvMat *Dx = 0, *Dy = 0, *D2x = 0, *D2y = 0, *Dxy = 0;
509 int buf_size = 1 << 12;
511 CV_FUNCNAME( "cvPreCornerDetect" );
515 int i, j, y, dst_y = 0, max_dy, delta = 0;
516 int temp_step = 0, d_step;
517 uchar* shifted_ptr = 0;
519 int stage = CV_START;
520 CvSobelFixedIPPFunc ipp_sobel_vert = 0, ipp_sobel_horiz = 0,
521 ipp_sobel_vert_second = 0, ipp_sobel_horiz_second = 0,
523 CvSize el_size, size, stripe_size;
527 CvMat stub, *src = (CvMat*)srcarr;
528 CvMat dststub, *dst = (CvMat*)dstarr;
529 bool use_ipp = false;
531 CV_CALL( src = cvGetMat( srcarr, &stub ));
532 CV_CALL( dst = cvGetMat( dst, &dststub ));
534 if( CV_MAT_TYPE(src->type) != CV_8UC1 && CV_MAT_TYPE(src->type) != CV_32FC1 ||
535 CV_MAT_TYPE(dst->type) != CV_32FC1 )
536 CV_ERROR( CV_StsUnsupportedFormat, "Input must be 8uC1 or 32fC1, output must be 32fC1" );
538 if( !CV_ARE_SIZES_EQ( src, dst ))
539 CV_ERROR( CV_StsUnmatchedSizes, "" );
541 if( aperture_size == CV_SCHARR )
542 CV_ERROR( CV_StsOutOfRange, "CV_SCHARR is not supported by this function" );
544 if( aperture_size < 3 || aperture_size > 7 || !(aperture_size & 1) )
545 CV_ERROR( CV_StsOutOfRange,
546 "Derivative filter aperture size must be 3, 5 or 7" );
548 depth = CV_MAT_DEPTH(src->type);
549 d_depth = depth == CV_8U ? CV_16S : CV_32F;
551 size = cvGetMatSize(src);
552 aligned_width = cvAlign(size.width, 4);
554 el_size = cvSize( aperture_size, aperture_size );
555 el_anchor = cvPoint( aperture_size/2, aperture_size/2 );
557 if( aperture_size <= 5 && icvFilterSobelVert_8u16s_C1R_p )
561 ipp_sobel_vert = icvFilterSobelVert_8u16s_C1R_p;
562 ipp_sobel_horiz = icvFilterSobelHoriz_8u16s_C1R_p;
563 ipp_sobel_vert_second = icvFilterSobelVertSecond_8u16s_C1R_p;
564 ipp_sobel_horiz_second = icvFilterSobelHorizSecond_8u16s_C1R_p;
565 ipp_sobel_cross = icvFilterSobelCross_8u16s_C1R_p;
567 else if( depth == CV_32F )
569 ipp_sobel_vert = icvFilterSobelVert_32f_C1R_p;
570 ipp_sobel_horiz = icvFilterSobelHoriz_32f_C1R_p;
571 ipp_sobel_vert_second = icvFilterSobelVertSecond_32f_C1R_p;
572 ipp_sobel_horiz_second = icvFilterSobelHorizSecond_32f_C1R_p;
573 ipp_sobel_cross = icvFilterSobelCross_32f_C1R_p;
577 if( ipp_sobel_vert && ipp_sobel_horiz && ipp_sobel_vert_second &&
578 ipp_sobel_horiz_second && ipp_sobel_cross )
580 CV_CALL( tempsrc = icvIPPFilterInit( src, buf_size, el_size ));
581 shifted_ptr = tempsrc->data.ptr + el_anchor.y*tempsrc->step +
582 el_anchor.x*CV_ELEM_SIZE(depth);
583 temp_step = tempsrc->step ? tempsrc->step : CV_STUB_STEP;
584 max_dy = tempsrc->rows - aperture_size + 1;
589 ipp_sobel_vert = ipp_sobel_horiz = 0;
590 ipp_sobel_vert_second = ipp_sobel_horiz_second = ipp_sobel_cross = 0;
591 dx_filter.init_deriv( size.width, depth, d_depth, 1, 0, aperture_size );
592 dy_filter.init_deriv( size.width, depth, d_depth, 0, 1, aperture_size );
593 d2x_filter.init_deriv( size.width, depth, d_depth, 2, 0, aperture_size );
594 d2y_filter.init_deriv( size.width, depth, d_depth, 0, 2, aperture_size );
595 dxy_filter.init_deriv( size.width, depth, d_depth, 1, 1, aperture_size );
596 max_dy = buf_size / src->cols;
597 max_dy = MAX( max_dy, aperture_size );
600 CV_CALL( Dx = cvCreateMat( max_dy, aligned_width, d_depth ));
601 CV_CALL( Dy = cvCreateMat( max_dy, aligned_width, d_depth ));
602 CV_CALL( D2x = cvCreateMat( max_dy, aligned_width, d_depth ));
603 CV_CALL( D2y = cvCreateMat( max_dy, aligned_width, d_depth ));
604 CV_CALL( Dxy = cvCreateMat( max_dy, aligned_width, d_depth ));
605 Dx->cols = Dy->cols = D2x->cols = D2y->cols = Dxy->cols = size.width;
608 max_dy -= aperture_size - 1;
609 d_step = Dx->step ? Dx->step : CV_STUB_STEP;
613 factor = 1 << (aperture_size - 1);
616 factor = 1./(factor * factor * factor);
618 aperture_size = aperture_size * 10 + aperture_size;
620 for( y = 0; y < size.height; y += delta )
624 delta = MIN( size.height - y, max_dy );
625 CvRect roi = cvRect(0,y,size.width,delta);
626 CvPoint origin=cvPoint(0,0);
628 if( y + delta == size.height )
629 stage = stage & CV_START ? CV_START + CV_END : CV_END;
631 dx_filter.process(src,Dx,roi,origin,stage);
632 dy_filter.process(src,Dy,roi,origin,stage);
633 d2x_filter.process(src,D2x,roi,origin,stage);
634 d2y_filter.process(src,D2y,roi,origin,stage);
635 stripe_size.height = dxy_filter.process(src,Dxy,roi,origin,stage);
639 delta = icvIPPFilterNextStripe( src, tempsrc, y, el_size, el_anchor );
640 stripe_size.height = delta;
642 IPPI_CALL( ipp_sobel_vert( shifted_ptr, temp_step,
643 Dx->data.ptr, d_step, stripe_size, aperture_size ));
644 IPPI_CALL( ipp_sobel_horiz( shifted_ptr, temp_step,
645 Dy->data.ptr, d_step, stripe_size, aperture_size ));
646 IPPI_CALL( ipp_sobel_vert_second( shifted_ptr, temp_step,
647 D2x->data.ptr, d_step, stripe_size, aperture_size ));
648 IPPI_CALL( ipp_sobel_horiz_second( shifted_ptr, temp_step,
649 D2y->data.ptr, d_step, stripe_size, aperture_size ));
650 IPPI_CALL( ipp_sobel_cross( shifted_ptr, temp_step,
651 Dxy->data.ptr, d_step, stripe_size, aperture_size ));
654 for( i = 0; i < stripe_size.height; i++, dst_y++ )
656 float* dstdata = (float*)(dst->data.ptr + dst_y*dst->step);
658 if( d_depth == CV_16S )
660 const short* dxdata = (const short*)(Dx->data.ptr + i*Dx->step);
661 const short* dydata = (const short*)(Dy->data.ptr + i*Dy->step);
662 const short* d2xdata = (const short*)(D2x->data.ptr + i*D2x->step);
663 const short* d2ydata = (const short*)(D2y->data.ptr + i*D2y->step);
664 const short* dxydata = (const short*)(Dxy->data.ptr + i*Dxy->step);
666 for( j = 0; j < stripe_size.width; j++ )
668 double dx = dxdata[j];
669 double dx2 = dx * dx;
670 double dy = dydata[j];
671 double dy2 = dy * dy;
673 dstdata[j] = (float)(factor*(dx2*d2ydata[j] + dy2*d2xdata[j] - 2*dx*dy*dxydata[j]));
678 const float* dxdata = (const float*)(Dx->data.ptr + i*Dx->step);
679 const float* dydata = (const float*)(Dy->data.ptr + i*Dy->step);
680 const float* d2xdata = (const float*)(D2x->data.ptr + i*D2x->step);
681 const float* d2ydata = (const float*)(D2y->data.ptr + i*D2y->step);
682 const float* dxydata = (const float*)(Dxy->data.ptr + i*Dxy->step);
684 for( j = 0; j < stripe_size.width; j++ )
686 double dx = dxdata[j];
687 double dy = dydata[j];
688 dstdata[j] = (float)(factor*(dx*dx*d2ydata[j] + dy*dy*d2xdata[j] - 2*dx*dy*dxydata[j]));
700 cvReleaseMat( &D2x );
701 cvReleaseMat( &D2y );
702 cvReleaseMat( &Dxy );
703 cvReleaseMat( &tempsrc );