I have this plot:
and want to flatten its baseline/reduce offset using Matlab.
Basically like a baseline correction for a spectrum but here I've got a mesh and can't get my head around it how to flatten its baseline when dealing with a matrix? Basically the dot should stay but the surrounding is actually zero. The noise can stay, though.
Here is the image:
I am wondering if something like this works:
for x=1:1201
for y=1:1201
Ibasetest = polyfit(x,y,1);
end
end
Simply put do a baseline for each X along Y for Z data. But I can't get it to work. :(
Note: Another method to attempt may include moving/windowing averages to calculate the local amount to offset by.
Method 1: Discrete Cosine Transform (DC Offset Removal)
Converts the image into the frequency domain uses the Discrete Fourier Transform (DCT). Removes the DC coefficient in the top-left corner (set to zero) of the matrix and convert it back to the spatial domain using the Inverse Discrete Fourier Transform (IDCT).
Key Discrete Cosine Transform (DCT) Filtering Code Lines
Method 2: Standard Uniform Offset (no-tilt accommodation)
Uses a constant value and subtracts that across the whole image matrix.
Test Image 1: Using Lowest Intensity to Calculate Offset
Test Image 2: Using Average/Mean to Calculate Offset
Using MATLAB version: R2019b