First-order and second-order partial derivatives in image processing

Source: Internet
Author: User

1. First-order difference:

 

2. derivation and approximation of second-order partial derivatives:

 

3. the above formula is centered on the point (I + 1, J), and the second-order partial derivative that can be centered on (I, j) with I for I + 1 is as follows:

 

4. Likewise:

 

5. Further derivation:

 

6. In this way, we can use other first-order partial guidance definitions, such as sift feature opencv, to implement the first-and second-order partial guidance in the version:

/* <Br/> computes the partial derivatives in X, Y, and scale of a pixel in the dog <br/> Scale Space pyramid. </P> <p> @ Param dog_pyr dog Scale Space pyramid <br/> @ Param octv pixel's Ave ave in dog_pyr <br/> @ Param intvl pixel's interval in octv <br/> @ Param R pixel's image row <br/> @ Param C pixel's image Col </P> <p> @ return returns the vector of partial derivatives pixel I <br/> {di/dx, DI/Dy, DI/DS} ^ t as a cvmat * <br/> */<br/> static cvmat * deriv_3d (iplimage *** dog_pyr, int octv, int intvl, int R, int c) <br/>{< br/> cvmat * di; <br/> double dx, Dy, DS; </P> <p> dx = (pixval32f (dog_pyr [octv] [intvl], R, C + 1) -<br/> pixval32f (dog_pyr [octv] [intvl], R, C-1)/2.0; <br/> DY = (pixval32f (dog_pyr [octv] [intvl], R + 1, C)-<br/> pixval32f (dog_pyr [octv] [intvl], R-1, c)/2.0; <br/> DS = (pixval32f (dog_pyr [octv] [intvl + 1], R, c)-<br/> pixval32f (dog_pyr [octv] [intvl-1], R, c)/2.0; </P> <p> di = cvcreatemat (3, 1, cv_64fc1); <br/> cvmset (Di, 0, 0, dx ); <br/> cvmset (Di, 1, 0, Dy); <br/> cvmset (Di, 2, 0, DS); </P> <p> return di; <br/>}</P> <p>/* <br/> computes the 3D Hessian matrix for a pixel in the dog Scale Space pyramid. </P> <p> @ Param dog_pyr dog Scale Space pyramid <br/> @ Param octv pixel's Ave ave in dog_pyr <br/> @ Param intvl pixel's interval in octv <br/> @ Param R pixel's image row <br/> @ Param C pixel's image Col </P> <p> @ return returns the Hessian matrix (below) for pixel I as a cvmat * </P> <p>/ixx ixy ixs/<br> <br/> | ixy iyy IYS | <br> <br/>/ixs iys iss/<br/> */<br/> static cvmat * hessian_3d (iplimage *** dog_pyr, int octv, int intvl, int R, int c) <br/>{< br/> cvmat * h; <br/> Double V, dxx, dyy, DSS, dxy, dxS, DYS; </P> <p> V = pixval32f (dog_pyr [octv] [intvl], R, C ); <br/> dxx = (pixval32f (dog_pyr [octv] [intvl], R, C + 1) + <br/> pixval32f (dog_pyr [octv] [intvl], R, c-1)-2 * V); <br/> dyy = (pixval32f (dog_pyr [octv] [intvl], R + 1, C) + <br/> pixval32f (dog_pyr [octv] [intvl], R-1, c)-2 * V ); <br/> DSS = (pixval32f (dog_pyr [octv] [intvl + 1], R, c) + <br/> pixval32f (dog_pyr [octv] [intvl-1], R, c)-2 * V); <br/> dxy = (pixval32f (dog_pyr [octv] [intvl], R + 1, C + 1) -<br/> pixval32f (dog_pyr [octv] [intvl], R + 1, C-1)-<br/> pixval32f (dog_pyr [octv] [intvl], R-1, c + 1) + <br/> pixval32f (dog_pyr [octv] [intvl], R-1, C-1)/4.0; <br/> DxS = (pixval32f (dog_pyr [octv] [intvl + 1], R, C + 1) -<br/> pixval32f (dog_pyr [octv] [intvl + 1], R, C-1)-<br/> pixval32f (dog_pyr [octv] [intvl-1], R, c + 1) + <br/> pixval32f (dog_pyr [octv] [intvl-1], R, C-1)/4.0; <br/> DYS = (pixval32f (dog_pyr [octv] [intvl + 1], R + 1, C) -<br/> pixval32f (dog_pyr [octv] [intvl + 1], R-1, c)-<br/> pixval32f (dog_pyr [octv] [intvl-1], R + 1, c) + <br/> pixval32f (dog_pyr [octv] [intvl-1], R-1, c)/4.0; </P> <p> H = cvcreatemat (3, 3, cv_64fc1); <br/> cvmset (H, 0, 0, dxx); <br/> cvmset (H, 0, 1, dxy ); <br/> cvmset (H, 0, 2, DxS); <br/> cvmset (H, 1, 0, dxy); <br/> cvmset (H, 1, 1, dyy); <br/> cvmset (H, 1, 2, Dys); <br/> cvmset (H, 2, 0, DxS ); <br/> cvmset (H, 2, 1, Dys); <br/> cvmset (H, 2, 2, DSS); </P> <p> return h; <br/>}

 

Refer:

(1) http://hi.baidu.com/shareshow/blog/item/34abdf544725cf54d109069b.html

(2) opencv Implementation of Sift

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.