Using sgolayfilt in derivative analysis of absorption images

3 ビュー (過去 30 日間)
Arnab Paul
Arnab Paul 2025 年 6 月 27 日
コメント済み: Walter Roberson 2025 年 6 月 28 日
I want to apply this equation to my absorption images at 655 nm
This code enables me to do that
fileDirectory = "/Volumes/Extreme_SSD/HPLC validation images";
filename = dir(fullfile(fileDirectory, '*aph.nc'));
nFileDirectory = length(filename);
%create directories for the chlorophyll (yearwise)
outputFolder = "/Volumes/Extreme_SSD/HPLC validation images";
for i=1:nFileDirectory
nFileAph = strcat(filename(i).folder, "/", filename(i).name);
ncdisp(nFileAph);
info = ncinfo(nFileAph);
dim = cell2mat({info.Variables.Dimensions});
ncol = dim(2).Length;
nrow = dim(1).Length;
aph654 = ncread(nFileAph, "a_ph_654");
aph656 = ncread(nFileAph, 'a_ph_656');
deltaLambda = 1; % nm
% derivative of 655
aph_deriv_655 = (aph656 - aph654) / (2 * deltaLambda);
end
now I am confused how to use filter such as sgolayfilt (window = 7, wavlength gap 5 nm) in the derived image.
  1 件のコメント
Walter Roberson
Walter Roberson 2025 年 6 月 28 日
dim = cell2mat({info.Variables.Dimensions});
It seems likely to me that the above line could be coded as
dim = [info.Variables.Dimensions];

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2025 年 6 月 27 日
The sgolayfilt function is used in signal processing of one-dimensional signals, not image processing of two-dimensional arrays. It creates a FIR smoothing filter (essentially a lowpass filter), however it is not obvious to me how your 'window' and wavelength gap would translate to framelength and polynomial order. It operates on each column of a matrix. (As a general rule, I use a third-order polynomial, and experiment with the framelength to get the result I want.) Filtering your matrix using sgolayfilt, transposing it and filtering it a second time using the same sgolayfilt call, and transposing it back to the original orientation could work. You will have to experiment to see if that produces an acceptable result.
The imfilter function can do image filtering, however it requires a multidimensional filter, and sgolay creates a unidimensional filter. It is not obvious how vector operations on two sgolay filters (not using sgolayfilt) would work to create a two-dimensional filter and retain the desired spectral characteristics.
What do you actually want to do?
  4 件のコメント
Arnab Paul
Arnab Paul 2025 年 6 月 27 日
is their any example how to filter using Gaussian filter?
Star Strider
Star Strider 2025 年 6 月 28 日
Not directly. See the documentation on imfilter for an example using a 'motion' filter.
It would probably be best for you to use the imgaussfilt function, since the Gaussian fspecial filter is no longer recommended.
(Answers is having serious problems currently. My apologies for the delay.)

サインインしてコメントする。

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by