How can I accurately get the fringes of this profile.

조회 수: 8 (최근 30일)
Vahram Voskerchyan
Vahram Voskerchyan 2025년 2월 17일
댓글: Mathieu NOE 2025년 2월 18일
I have the following profile and I want to get the fringes (peaks along the fringes) that are shown.
What I want is accurately get the sape of this fringes I did edge detection but I don't think it's rigorous for this type of calculations. I have attached the .mat file if you want to look. All I want to is accuratly follow the local maxima of these fringes as shown in the figure below:
Did someone encounter similar problem. Thank you very much for the help.
  댓글 수: 2
Walter Roberson
Walter Roberson 2025년 2월 17일
I wonder if it would work to do a findpeaks() across each row of the image, and trace the evolution?
It might help to start from the middle row and track down until each peak disappears, and then go up and track upwards until each peak disappears.
Vahram Voskerchyan
Vahram Voskerchyan 2025년 2월 18일
yes! I think it's a good idea here is my approach based on your comment.
load('fringes.mat'); % Load Data
T = abs(P_resize); % Convert to absolute values
figure, imagesc(T), colormap(jet);
colorbar;
hold on;
minpeakdist = 3; % Minimum distance between peaks
minpeakh = 3e-5; % Minimum peak height
x_coords = [];
y_coords = [];
% Process all rows from top to bottom
for k = 1:size(T,1)
tex = T(k,:);
[pks, locs] = findpeaks(tex, 'MinPeakDistance', minpeakdist, 'MinPeakHeight', minpeakh);
if ~isempty(locs)
x_coords = [x_coords, X(k, locs)];
y_coords = [y_coords, Y(k, locs)];
end
end
% Plot detected fringes
figure;
plot(x_coords, y_coords, 'r*', 'markersize', 2);
hold on;
xlabel('X Coordinate');
ylabel('Y Coordinate');
title('Detected Fringes in Real-World Coordinates');
colorbar;

댓글을 달려면 로그인하십시오.

채택된 답변

Mathieu NOE
Mathieu NOE 2025년 2월 17일
hello
this is a very simple (simplistic ?) approach
I used peakseek for faster execution vs findpeaks but you can use your own prefered tool for this job
of course I suspect you would have prefered a solution where each line data is stored in a specific cell array
here it's just the whole points , not yet organized.
load('fringes.mat')
T = abs(P_resize);
figure,imagesc(T)
colorbar
hold on
minpeakdist = 3;
minpeakh = 3e-5;
for k = 20:size(T,1)
tex = T(k,:);
[locs{k}, pks{k}]=peakseek(tex,minpeakdist,minpeakh);
plot(locs{k},k*ones(size(locs{k})),'r*','markersize',2);
end
  댓글 수: 6
Mathieu NOE
Mathieu NOE 2025년 2월 18일
forgot to say : you will need the below and attached functions for the baseline correction
here I had to make a tiny modification in baseline to avoid sometimes an error :
% if A(i-1)<A(i-2) && A(i-1)<A(i) % original code
if (A(i-1)<A(i-2) && A(i-1)<A(i)) || n>=l % mod MN : added condition (n>=l) to avoid error
function [Base, Corrected_Spectrum]=baseline(Spectrum)
%Input
%-------
%Spectrum: vector of size (N*1)
%Output
%-------
%Base: Identified Baseline vector of size (N*1)
%Corrected_Spectrum: Corrected Spectrum vector of size (N*1)
l=length(Spectrum);
lp=ceil(0.5*l);
initial_Spectrum=[ones(lp,1)*Spectrum(1) ; Spectrum ; ones(lp,1)*Spectrum(l)];
l2=length(initial_Spectrum);
S=initial_Spectrum;
n=1;
flag1=0;
while flag1==0
n=n+2;
i=(n-1)/2;
[Baseline, stripping]=peak_stripping(S,n);
A(i)=trapz(S-Baseline);
Stripped_Spectrum{i}=Baseline;
S=Baseline;
if i>3
% if A(i-1)<A(i-2) && A(i-1)<A(i) % original code
if (A(i-1)<A(i-2) && A(i-1)<A(i)) || n>=l % mod MN : added condition (n>=l) to avoid error
i_min=i-1;
flag1=1;
end
end
end
Base=Stripped_Spectrum{i_min};
Corrected_Spectrum=initial_Spectrum-Base; Corrected_Spectrum=Corrected_Spectrum(lp+1:lp+l);
Base=Base(lp+1:lp+l);
end
Mathieu NOE
Mathieu NOE 2025년 2월 18일
I don't have the Stats Toolbox, but if you have , you could try with Spectral Clustering

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by