just detrend

performs line-by-line detrending or flattening of a matrix up to arbitrary expansion order
302 Downloads
Updated 10 Oct 2013

View License

just detrend. Simple script for line-by-line detrending of a matrix. Useful for flattening topographic images such as from AFM or STM. Note that this is not a plane fit but a line-by-line flattening/detrending. This script makes use of the polyfit function and can detrend/flatten up to arbitrary expansion order.

jdetrend(Img,dimension,order)
Img = image data matrix. dimension = 1 or 2 - detrend along rows(1) or columns(2).
order = expansion order in polyfit.

Example:
To remove trends up to cubic order from an AFM image that was scanned horizontally:
dataOut=jdetrend(dataIn,2,3);

Cite As

Shawn Divitt (2026). just detrend (https://www.mathworks.com/matlabcentral/fileexchange/43834-just-detrend), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on DICOM Format in Help Center and MATLAB Answers
Version Published Release Notes
1.1.0.0

V2 - changed the function so that it can work with non-square matrices/images/arrays

1.0.0.0