just detrend
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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
