5.0

5.0 | 1 rating Rate this file 10 Downloads (last 30 days) File Size: 3.36 KB File ID: #29330

Neighbour points in a matrix

by Ronald Ouwerkerk

 

09 Nov 2010

Calculate the linear indices of neighboring points in a matrix and the distance from the original.

| Watch this File

File Information
Description

Calculate the linear indices for neighboring points in a matrix. You need to supply one or more linear indices for the point(s) of origin and the dimensions of the matrix. You will get a list will linear indices to all neighboring points. The function also creates a vector with the distances from the input point(s) based on the third function argument: an array with inter point distances in all dimensions. This argument defaults to unit distances.
The third output reports the number of neighbours found in within the matrix. For 2D we expect up to 8, for 3D up to 26 etc..
For points near the edge of the matrix the output may contain fewer points. For single index input all points outside the matrix and the origin point itself are removed. For multiple point input only the input point is removed.
This function help in medical image processing when applying a filter on 2D or 3D images based on actual distance rather than index distance e.g for image smoothing in 3D.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
09 Nov 2010 Sean de

Very Nice!
Only thing I had to change was to remove the 'u' in 'neighbour'

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrix indexing euclidean distance Ronald Ouwerkerk 09 Nov 2010 12:30:00

Contact us at files@mathworks.com