No BSD License  

2.66667

2.7 | 3 ratings Rate this file 13 Downloads (last 30 days) File Size: 2.45 KB File ID: #7906

Inverse Gradient

by

 

23 Jun 2005 (Updated )

The inverse function of gradient().

| Watch this File

File Information
Description

INVGRADIENT Basically the opposite of gradient(), aka Inverse Gradient.

F_bar = INVGRADIENT(dFx,dFy) reverses GRADIENT(F), where unit spacing is assumed.

F_bar = INVGRADIENT(dFx,dFy,H), where H is scalar, uses H as the spacing between points.

F_bar = INVGRADIENT(dFx,dFy,Hx,Hy) is basically the same, except that both x- and y-spacings are specified. Obviously, the DC offset of the integrated function is arbitrary. Also,

INVGRADIENT is limited to 2-dimensions at the moment, ie no 3-dimensional matrices, or vectors. If dFx and dFy aren't self-consistent then no exact solution can be integrated. In this case% the optimal solution, in the least squares sense, will be found. So if you do F_bar = INVGRADIENT(dFx,dFy), F_bar will be found such that doing [dFx_ dFy_] = GRADIENT(F_bar) will give you dFx_ and dFy_ that are as close as possible to the original dFx and dFy.
  
Patrick Lu
April 5, 2005
If this doesn't work right, email patlu@nospam.stanford.edu, w/o the nospam.

Acknowledgements

This file inspired Inverse (Integrated) Gradient.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
19 Jan 2006 Bing Li

Good concept, but you are not a MATLAB-thinking guy. Some improvement suggestion
1. try to use sparse() and diag() to form your Gx and Gy, much faster than loop(C/C++ way).
2. Similarly, use sparse() and diag() for G2, or you can form G2 directly without Gx Gy. For God sake, please do that. G2 is a 2NM-by-NM double FULL matrix, if the F is N-by-M matrix. That's (NM)^2*2*8 Bytes, for a normal size image N=M=512, that's 2^40 Bytes = 1024 GB, no one has such RAM.
3. why do you use pinv()? that's very expensive, and I don't see it's neccessary. Try '\'.

16 Dec 2005 tom white  
19 Aug 2005 Bartek Zielinski

Very good stuff! Very accurate, the penalty is in the speed of the algorithm,though...
Looking forward into 3D version!

Contact us