MATLAB Functions for Computer Vision and Image Analysis
2008-10-12 12:44
519 查看
MATLAB Functions for Computer Vision and Image Analysis
Peter Kovesi
School of Computer Science & Software Engineering
The University of Western Australia
Crawley, Western Autralia. 6009
Please report any bugs and/or suggest enhancements toPlease note that I receive so many mail messages regarding this site that I have difficulty responding to them all. Much as I would like to, I do not have the time to provide an on-line vision problem solving service! However, I will endeavor to respond to mail that directly concerns the use of individual functions.
Cheers,
Peter Kovesi
The complete set of these functions is available as a gzipped tar file MatlabFns.tar.gz for Unix users
Note that I develop my code under Linux, I have not tested these functions under Windows.
Feature detection via Phase Congruency
phasecong.m Code for calculating phase congruency in an image. Phase congruency is an illumination and contrast invariant measure of feature significance. It also correctly detects features at all kind of phase angle, and not just step features with a phase angle of 0 or 180 degrees. Note this function also returns a feature type image.
phasecong2.m Beta version of new phase congruency code. This function supersedes phasecong.m above. It calculates both an edge and corner map.
dispfeat.m This function provides visualisation and statistics of the different feature types found in an image by phasecong. Typically you will find a broad distribution of all feature types between step edges and lines. This function needs edgelink.m (see below).
odot.m Demonstrates the actions of the 'Odot' and 'Oslash' operators on a 1D signal. These operators allow one to decompose and combine signals in a way that is consistent with the Local Energy model of feature perception.
phase symmetry image |
gaborconvolve.m Code for convolving an image with a bank of log-Gabor filters. A pre-processing step for texture analysis, feature classification, etc.
An explanation of the implementation of convolution with log-Gabor filters used in the functions above.
References:
Peter Kovesi, "Symmetry and Asymmetry From Local Phase". AI'97, Tenth Australian Joint Conference on Artificial Intelligence. 2 - 4 December 1997. Proceedings - Poster Papers. pp 185-190.
Peter Kovesi, "Image Features From Phase Congruency". Videre: A Journal of Computer Vision Research. MIT Press. Volume 1, Number 3, Summer 1999.
Peter Kovesi, "Edges Are Not Just Steps". Proceedings of ACCV2002 The Fifth Asian Conference on Computer Vision, Melbourne Jan 22-25, 2002. pp 822-827.
Peter Kovesi, "Phase Congruency Detects Corners and Edges". The Australian Pattern Recognition Society Conference: DICTA 2003. December 2003. Sydney. pp 309-318.
Non-maxima suppression and hysteresis thresholding
nonmaxsup.m Code for performing non-maxima suppression for edge images. Now optionally returns sub-pixel edge locations (Sept 2004).
nonmaxsuppts.m Code for performing non-maxima suppression and thresholding of points generated by a corner detector.
hysthresh.m code for performing hysteresis thresholding.
Test grating for edge detection
Test image | Canny edge image | Phase congruency | Colour coded for feature type |
Image denoising
noisecomp.m Code for denoising images. This code differs from standard wavelet denoising techniques in that it uses non-orthogonal wavelets, and unlike existing techniques, ensures that phase information is preserved in the image. Phase information is of crucial importance to human visual perception. Also, this code does have an effective way of determining threshold levels automatically.
Reference:
Peter Kovesi, "Phase Preserving Denoising of Images". The Australian Pattern Recognition Society Conference: DICTA'99. December 1999. Perth WA. pp 212-217.
Surface normals to Surfaces
Surface Normals | Surface Reconstruction |
Note that the reconstruction is only valid up to a scale factor (which can be corrected for). However the reconstruction process is very robust to noise and to missing data values. Reconstructions (up to positive/negative shape ambiguity) are possible where there is an ambiguity of pi in tilt values. Low quality reconstructions are also possible with just slant, or just tilt data alone. However, if you have full gradient information you are better off with the Frankot Chellappa algorithm below.
frankotchellappa.m An implementation of Frankot and Chellappa's algorithm for constructing an integrable surface from gradient information. If you have full gradient information in x and y this is probably the best algorithm to use. It is very simple, very fast and highly robust to noise. If you have surface normal information in the form of slant and tilt, and you have an ambiguity of pi in your tilt data, or only have slant, then try using shapeltsurf.m above.
grad2slanttilt.m Converts gradient values over a surface to slant and tilt angles.
slanttilt2grad.m Converts slant and tilt angles over a surface to gradients.
needleplotgrad.m Generates a needle plot given surface gradients over a surface.
needleplotst.m Generates a needle plot given slant and tilt values over a surface.
testp.m Generates a synthetic test surface along with its surface normals for testing shapeletsurf.
Reference:
Peter Kovesi, "Shapelets Correlated with Surface Normals Produce Surfaces". Technical Report 03-003, October 2003
An example of how much 3D shape you can get from very minimal surface normal information.
Scalogram calculation
scalogram.m Function to calculate the phase and amplitude scalograms of a 1D signal. The analysis is done using quadrature pairs of log Gabor wavelets.
Anisotropic diffusion
anisodiff.m Function to perform anisotropic diffusion of an image following Perona and Malik's algorithm. This process smoothes regions while preserving, and enhancing, the contrast at sharp intensity gradients.
Spatial feature detection
canny.m Canny edge detector incorporating modifications suggested by Fleck. (Note I believe the implementation of Canny within MATLAB's edge function does not follow Canny's original intentions in that there is no smoothing orthogonal to the filtering directions. However, in practice one hardly notices anything.)harris.m Harris corner detector.
Reference:
Scanned images of my photocopy of Harris and Stephens' paper 'A Combined Corner and Edge Detector'.
Edge linking and line segment fitting
image | edges | labeled edges | fitted line segments |
drawedgelist.m plots out a set of edge lists.
lineseg.m forms straight line segments fitted with a specified tolerance to the lists of connected edge points.
mergeseg.m is used by lineseg.m to merge co-linear segments that may have been separated in the edge linking process.
maxlinedev.m is also used by lineseg.m to calculate deviations of the edge lists from the fitted segments.
drawseg.m plots the fitted line segments.
selectseg.m allows you to interactively select segments from an image.
Example of using these functions above.
Grey scale transformation and enhancement
extractfields.m separates fields from a video frame, and optionally interpolates intermediate lines.interpfields.m interpolates lines on a field extracted from a video frame.
normalise.m rescales image values to 0-1.
adjcontrast.m adjusts image contrast using sigmoid function.
adjgamma.m adjusts image gamma.
greytrans.m allows you to interactively remap intensity values in a colour or greyscale image via a mapping function defined by a series of spline points. A feeble attempt at replicating xv's intensity mapping tool. It is not as fast but it does operate on floating point images allowing you to better preserve image fidelity. (Needs remapim.m). (Modified to work with colour images, March 2003).
remapim.m is a non-interactive version of greytrans that allows you to apply an intensity mapping to a colour or greyscale image using a mapping function determined experimentally with greytrans. Useful if you want to apply the same mapping function to a sequence of images. (Modified to work with colour images, March 2003).
histtruncate.m truncates ends of an image histogram. Useful for enhancing images with outlying values.
Frequency domain transformations
lowpassfilter.m constructs low-pass Butterworth filter.highpassfilter.m constructs high-pass Butterworth filter.
highboostfilter.m constructs high-boost Butterworth filter.
bandpassfilter.m constructs band-pass Butterworth filter.
homomorphic.m performs homomorphic filtering on an image. One of my favourite image enhancement techniques. (needs histtruncate.m and normalise.m)
psf.m generates a variety of point-spread functions. This function can be useful when manually specifying point-spread functions for Wiener filtering or with deconvolution functions such as the Richardson-Lucy algorithm (see the MATLAB image toolbox function deconvlucy.m).
psf2.m is identical to psf, it just has a different way of specifying the function shape which may be more convenient for some applications.
imspect.m plots image amplitude spectrum averaged over all orientations.
freqcomp.m demonstrates image reconstruction from its Fourier components.
Functions supporting projective geometry
image of beach | rectified beach |
homography1d.m computes the 2x2 1D homography of 3 or more points along a line.
homography2d.m computes the 3x3 2D homography of 4 or more points in a plane. This code follows the normalised direct linear transformation algorithm given by Hartley and Zisserman. It will give more accurate results than the simple linear solution used by 'invpersp' above. (needs normalise2dpts.m)
fundmatrix.m computes the fundamental matrix from 8 or more matching points in a stereo pair of images using the normalised 8 point algorithm.
normalise2dpts.m translates and normalises a set of 2D homogeneous points so that their centroid is at the origin and their mean distance from the origin is sqrt(2). This is used to improve the conditioning of any equations used to solve homographies, fundamental matrices etc.
hnormalise.m normalises an array of homogeneous coordinates so that their scale parameter is 1. Points at infinity are unchanged.
imTrans.m applies a homogeneous transform to an image.
digiplane.m allows you to digitise and transform points within a planar region in an image.
equalAngleConstraint.m Affine transform constraints given two equal angles.
knownAngleConstraint.m Affine transform constraints given a known angle.
lengthRatioConstraint Affine transform constraints given a length ratio.
circleintersect.m Finds intersection of two circles. Use this function to solve for affine transformation constraints.
circle.m Draws a circle.
hcross.m Homogeneous cross product, result normalised to s = 1.
hline.m Plot 2D lines defined in homogeneous coordinates.
homoTrans 2D homogeneous transformation of points/lines.
plotPoint.m Plots point with specified mark and optional text label.
Lens Distortion Correction
original image | corrected image |
imlenstransform.m This function applies or inverts a lens distortion transformation defined by first order coefficients to an image.
crookedness.m Returns a measure of the 'crookedness' of a set of lines. This is the objective function passed to the optimisation function by lensparam.m.
edgelistlenscorrect.m This function corrects for lens distortion defined by first order coefficients on an edgelist.
Example of the use of these functions.
These functions make use of:
drawedgelist.m, edgelink.m, lineseg.m, maxlinedev.m, mergeseg.m, implace.m, removenan.m, show.m, fitline.m
Matching
matchbycorrelation.m generates putative matches between previously detected feature points in two images by looking for points that are maximally correlated with each other within windows surrounding each point. Only points that correlate most strongly with each other in both directions are returned. This is a simple-minded N^2 comparison.Model fitting and Robust estimation
Putative matches obtained by matchbycorrelation.m | Inlying matches consistent with fundamental matrix |
ransacfitplane.m robustly fits a plane to 3D data points.
fitline.m least squares fit of a line to 2D data points.
fitplane.m least squares fit of a plane to 3D data points.
ransacfithomography.m robustly fits a homography to a set of putatively matched image points. (Corrected July 2004)
ransacfitfundmatrix.m robustly fits a fundamental matrix to a set of putatively matched image points.
iscolinear.m tests if 3 points are colinear, used by ransacfitplane and ransacfithomography.
Example of using these functions above to find the fundamental matrix.
testfitplane example of using ransacfitplane.m
Interesting images
noiseonf.m generates noise images with specified amplitude spectra. One can create pleasing cloud pattern images this way.
cloud9.m creates a movie sequence of noise images with specified amplitude spectra. Very relaxing.
derespolar.m Generates deresolved images in polar coordinates.
polartrans.m Generates a polar transformation of an image. A linear or logarithmic radius transformation can be specified.
circsine.m Generates a test image consisting of a circular sine wave grating.
ASCII Image Generation
matscii.m Function to generate ASCII images from grey scale images. A bit retro but may have applications for interesting text messages on your mobile phone!
Image Display, Image Writing and Miscellaneous
show.m This function displays an image, automatically setting the colour map to grey if it is a 2D image, or leaving it as colour otherwise, and setting the axes to be 'equal'. The image is also displayed as 'TrueSize', that is, pixels on the screen match pixels in the image. Finally a title corresponding to the image variable name is added. (Modified to work with subplots, March 2003)showfft.m displays the amplitude spectrum of an fft.
showlogfft.m displays the log amplitude spectrum of an fft.
imwritesc.m This function combines image rescaling and writing into the one function. If the image type is double image values are rescaled to the range 0-1 so that no overflow occurs when writing 8-bit intensity values. The image format to use is determined by MATLAB from the file ending. If the image type is of uint8 no rescaling is performed.
matprint.m This function prints out a matrix using a specified C style format string. Often you find that MATLAB's default number formats are not what you want. It is surprising that there is no convenient fine control of output format. I hope this function helps.
removenan Replaces NaN values in a matrix with a specified default value. Useful when you want to prevent NaNs from contaminating and destroying some operation on an array, for example, an FFT.
digipts.m Function to digitise points in an image. This function uses the cross-hair cursor provided by GINPUT. I find this is much more useable than the cursor used by IMPIXEL. In addition each location digitised is marked with a red '+'.
implace.m Function to place an image at a specified location within a larger image.
相关文章推荐
- MATLAB and Octave Functions for Computer Vision and Image Processing
- MATLAB and Octave Functions for Computer Vision
- Gabor filter for image processing and computer vision
- Deep Learning for Computer Vision with MATLAB and cuDNN(译文)
- 图像处理和计算机视觉中的Gabor滤波:Gabor filter for image processing and computer vision
- Deep Learning for Computer Vision with MATLAB and cuDNN
- Some Matrix manifolds (Lie group, Grassmann manifold and Riemannian manifold) for computer vision
- 计算机视觉和模式识别中的稀疏表示(Sparse Representation for Computer Vision and Pattern Recognition)
- Computer Graphics, Computer vision and Image processing
- ICCV Tutorial on Sparse Coding and Dictionary Learning for Image Analysis
- A Hybrid Computer Vision and Wi-Fi Doppler Radar System for Capturing the 3-D Hand Gesture Trajector
- 图像处理中的全局优化技术(Global optimization techniques in image processing and computer vision) (一)
- Computer Vision and Image Processing-3_Intensity Transformation-思维导图
- Software and Hardware for Data Analysis, Pattern Recognition and Image Processing
- Deep Learning for Computer Vision with Caffe and cuDNN
- Computer Vision and Image Understanding
- Computer Vision and Image Processing-4_Spatial Filtering-思维导图
- Computer Vision and Image Processing-5_Image Segmentation-思维导图
- 图像处理中的全局优化技术(Global optimization techniques in image processing and computer vision) (二)
- image processing and computer vision web site