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