## Feature tracking by template matchingYou provide templatematch with two images (A and B) and a set of coordinates in A that should be tracked. Templatematch will then cut out small templates around each point and calculate the similarity within a search region in image B. The measure of similarity will typically be normalized cross correlation. The 'optimal' displacement xy will be returned with sub-pixel precision. In its simplest form you can use templatematch thus: [du, dv, peakCorr, meanAbsCorr, pu, pv] = templatematch(A,B) Note: u,v refers to pixel coordinates in the code below. ` ` ` [du, dv, peakCorr, meanAbsCorr, pu, pv] = templatematch(A,B[,pu,pv][,parameter-value-pairs])` ` ` ` ` ` A,B: images` ` pu,pv: pixel coordinates in A that should be located in B. (Default is a regular grid)` ` ` ` ` ` ` ` TemplateWidth,TemplateHeight: Size of templates in A (Default: 21).` ` SearchWidth,SearchHeight: Size of search region in B (Default: TemplateWidth+40).` ` SuperSample: super sampling factor of input images for improved subpixel accuracy. (default=1)` ` Initialdu,Initialdv: initial guess of the displacement between A & B` ` super: supersampling factor (input to imresize)` ` ShowProgress: Boolean or cell-array of strings.` ` true (default) is used for a text progress bar.` ` A cell of strings is used to name the A & B images in a progress figure.` ` Method: 'NCC'(default), 'NORMXCORR2' or 'PC' (normalized cross correlation or phase correlation)` ` ` ` ` ` du,dv: displacement of each point in pu,pv. [A(pu,pv) has moved to B(pu+du,pv+dv)]` ` peakCorr: correlation coefficient of the matched template. ` ` meanAbsCorr: The mean absolute correlation coefficitent over the search` ` region is an estimate of the noise level.` ` pu,pv: actual pixel centers of templates in A (may differ slightly from inputs because of rounding). ` TODO: update figure so that it uses u,v for pixel coordinates rather than x,y. ## Template Width / Height:- Reduced resolution of output. Hi resolution is necessary for narrow outlet glaciers and more data also helps in post-processing to find erroneous results.
- Performance decreases with template size. This may be partly compensated by reducing the number of tracked points as the effective resolution is any decreased.
- Possibly greater total shear inside the template. Shear reduces the cross correlation and thus makes it harder to recognize the feature in image B.
## Search region size (SearchWidth/SearchHeight):## Super-sampling:You can specify a super sampling factor which will resample the template and search images in order to improve the sub-pixel precision. This super sampling factor can also be used to downsample the images (when super<1) to coarser resolution if you want to speed up the calculation at the expense of precision. This approach is used in the 'rock matching' of the Engabreen example. The good performance of super-sampling to achieve sub-pixel precision can be seen in Gilo and Kääb (2011). ## Initial guess of displacement (initialdu/initialdv):## Initialdu/initialdv can also be used as a mask by inserting nans at locations where## Showprogress## Methods## Outputs## Displacement (du,dv)## Match quality (peakCorr, meanAbsCorr)peakCorr is the maximum correlation coefficient found at the location of each match.meanAbsCorr is the average or typical correlation coefficient over the entire search window. The ratio peakCorr./meanAbsCorr can be interpreted as a signal-to-noise ratio and can be used to filter false matches. Advanced tip: Sometimes it works better to spatially smooth meanAbsCorr before evaluating the signal-to-noise ratio . ## Pre-processing imagesIn some cases you may improve the feature tracking by pre-processing the images. This FAQ page has a few suggestions for how you might pre-process the images. |

voxelviewshed calculates the viewshed over a DEM. The viewshed is all the locations that are potentially visible from a given location. ` USAGE: vis=voxelviewshed(X,Y,Z,camxyz)` ` ` ` INPUTS:` ` X,Y,Z: input DEM (regular grid).` ` camxyz: 3-element vector specifying viewpoint.` ` ` ` OUTPUT:` ` vis: boolean visibility matrix (same size as Z)` ` ` ` EXAMPLE:` ` [X,Y]=meshgrid(-299:300);` ` Z=abs(ifft2(ifftshift((hypot(Y,X)+1e-5).^(-2.1).*exp(rand(size(X))*2i*pi)))); %example terrain inspired by rafael.pinto` ` Z=(Z-Z(300,300))/std(Z(:)); camxyz=[0,0,0.5];` ` vis=voxelviewshed(X,Y,Z,camxyz);` ` clf;` ` surf(X,Y,Z,Z.*vis-~vis*2,'EdgeColor','none','FaceColor','interp');` ` hold on;` ` plot3(camxyz(1),camxyz(2),camxyz(3),'k*')` ` camlight` See also Engabreen feature tracking example for an example use case. The algorithm is custom made and very fast. Conceptually it works by draping curtains hanging down from the DEM grid points in progressively greater circles around the camera while keeping track of visually highest 'curtain point' for every compass direction. |

The camera model holds both all the internal camera parameters (focal lengths, distortion coefficients, etc) and all the external camera parameters (camera location and view direction). This class can be used to project back and forth between pixel and world coordinates once the camera parameters have been specified. It can also be used to calibrate the camera parameters given a set of ground control points. ## Setting up camera parametersYou setup the camera parameters using its contructor and then you can modify the parameters afterwards. E.g. like this: `cam=camera([446722 7396671 770]) %specifying world coordinates only` `cam.f=[6000 6000];` `cam.viewdir=[90 0 0]*pi/180; %looking north` The Engabreen and Schneefernerkopf examples show some practical use cases. There are additional ways the constructor can be called. Type " help camera.camera" on the matlab prompt to see the full help of the constructor. ## Calibrating camera parameters from ground control pointsIn this case the string '00000111000000000000' says that the 6,7,8th parameters should be free. The ordering here refers to the ordering in the "fullmodel" where 6-8 corresponds to the three view direction angle. So, in this case we are only optimizing the view direction of the camera. The Engabreen and Schneefernerkopf examples show how a simple radial distortion model is determined from the ground control points. Type " help camera.optimizeCam" on the matlab prompt for more details on how to use it. ## Projecting from world coordinates to image coordinates (3d to 2d)## Projecting from image coordinates to world coordinates (2d to 3d)`xyz=cam.invproject(uv,demX,demY,demZ)` The Engabreen example shows how this can be used in practice. Type " help camera.invproject" on the matlab prompt for more details on how to use it. ## How do you calculate the focal length in pixel units from the camera specifications? |