前言:本文,從一個模擬攝像機拍攝的光柵圖分析入手,嘗試找到該光柵圖的各個極值,從而來評估光柵的正弦特性:
1 提取數據:
拍攝的結構光條紋如下:
黃色的線,是用採樣軟件[imageJ]在結構光的拍攝條紋中選取準備分析的正弦數據:
[imageJ]同樣可以輸出DATA數據作爲數據分析的基礎:
數據爲excel的CVS的格式。
2 利用Matlab找一組模擬波形的極值
直接上代碼吧,也比較簡單。
clear all;
%init
%read data
data1 = xlsread('a.xlsx');
%find the maxim data
hold on;%mix the diagram
plot(data1);
grid on
[maxim,locs]=max(data1);
plot(locs,maxim,'O','color','R');
% find the peak data in the serial waveforms
peakdata = findpeaks(data1);
[peakdata,locs]=findpeaks(data1);
plot(locs,peakdata,'*','color','g');
%[~,locs]=findpeaks(data1);
%plot(locs,peakdata,'*','color','b');
%hold off
%find the mini
data2 = 255 - data1;
peakminidata = findpeaks(data2);
[peakminidata,locs2]=findpeaks(data2);
minidata = 255 - peakminidata;
plot(locs2,minidata,'*','color','b');
%plot(locs,peakdata,'*','color','R');
% mindata = findmini(data1);
解釋一下:
上面這段代碼,會讀取一段正弦波形的數據,然後分別在圖上標識出來最大值,極大值,極小值。
參考:
1Matlab中利用findpeaks找波峯和波谷
https://blog.csdn.net/it_beecoder/article/details/78681517
2 Matlab 官網 findpeaks的說明