How to calculate peak value and duration of signal in Image
Show older comments
Hello,I have the following Image originalimage.png i want to calculate the peak value of the signal and also the duration of the each signal, as i attached the image parameterinstersted.png in which i describes which values i am currently determing
How can i do it in MATLAB
1 Comment
Star Strider
on 27 Oct 2022
Accepted Answer
More Answers (2)
KALYAN ACHARJYA
on 26 Oct 2022
0 votes
There are many threds sillimar quaestions, calculate the FWHM and time duration of the signal, please refer
Hope it Helps!
2 Comments
Med Future
on 26 Oct 2022
KALYAN ACHARJYA
on 26 Oct 2022
Is that: Then getting the maximum distance white pixels from the max row number (same column case) consider as highest peak- Elcudian distance (But it is not the correct technical way to get the peak)?
The indexing in the image makes this a challenge, since they reflect back and in any event are non-monotonic, eliminating a straightforward solution and requiring a more intensive approach. The two peaks appear to be mirror images of each other, so I only analysed the left one here.
The Full-Width-Half-Maximum Value is 102.5 index units.
Try this —
Img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1169303/OriginalImage.png');
CC = bwconncomp(Img,8);
PIL = CC.PixelIdxList;
[yc,xc] = cellfun(@(x)ind2sub(CC.ImageSize,x), PIL, 'Unif',0);
xy = [cell2mat(xc.') cell2mat(yc.')];
xy(:,2) = max(xy(:,2)) - xy(:,2);
xyh = xy(1:fix(size(xy,1)/2),:);
figure
plot(1:size(xyh,1), xyh(:,1), 'DisplayName','Row Index')
hold on
plot(1:size(xyh,1), xyh(:,2), 'DisplayName','Column Index')
hold off
grid
legend('Location','best')
figure
plot((250:350), xyh(250:350,1), 'DisplayName','Row Index')
hold on
plot((250:350), xyh(250:350,2), 'DisplayName','Column Index')
hold off
grid
title('Original Vectors')
legend('Location','best')
figure
plot(xyh(:,1), xyh(:,2))
grid
xlabel('Row Index')
ylabel('Column Index)')
[maxv,ixh] = max(xyh(:,2));
xv1 = 1:ixh; % Lower Section Index Vector
xv2 = ixh+1:size(xyh,1); % Upper Section Index Vector
figure
plot(xyh(xv1,1), xyh(xv1,2), 'DisplayName','Lower Section')
hold on
plot(xyh(xv2,1), xyh(xv2,2), 'DisplayName','Upper Section')
hold off
grid
xlabel('Row Index')
ylabel('Column Index)')
legend('Location','best')
Lv1 = diff([0; xyh(xv1,2)]) >= 1; % Select Indices To Elliminate Discontinuities
Lv2 = diff([0; xyh(xv2,2)]) <= 1; % Select Indices To Elliminate Discontinuities
figure
plot(xv1(Lv1(250:350)), xyh(xv1(Lv1(250:350)),1), 'DisplayName','Selected Row Index')
hold on
plot(xv1(Lv1(250:350)), xyh(xv1(Lv1(250:350)),2), 'DisplayName','Selected Column Index')
hold off
grid
title('Selected-Element Vectors')
xlabel('Absolute Index')
legend('Location','best')
ixv1 = xv1(Lv1); % Selected Indices
ixv2 = xv2(Lv2); % Selected Indices
yq = max(xyh(:,2))/2
ix1 = find(diff(sign(xyh(ixv1,2)-yq)))+[0 1]; % Approximate Index
xq(1) = interp1(xyh(ixv1(ix1),2), xyh(ixv1(ix1),1), yq); % Interpolate
ix2 = find(diff(sign(xyh(ixv2,2)-yq)))+[0 1]; % Approximate Index
xq(2) = interp1(xyh(ixv2(ix2),2), xyh(ixv2(ix2),1), yq); % Interpolate
FWHM = xq(2)- xq(1) % FWHM: Desired Result (Units: Index)
figure
plot(xyh(ixv1,1), xyh(ixv1,2))
hold on
plot(xyh(ixv2,1), xyh(ixv2,2))
hold off
grid
xlabel('Row Index')
ylabel('Column Index)')
.
2 Comments
Med Future
on 28 Oct 2022
Star Strider
on 28 Oct 2022
The ‘102.5’ value is the full-width-half-maximum (FWHM) value of the peak. (Because of the nature of the data, it is extremely difficult to draw it on the plot.) This is typically what is referred to as the ‘width’ of a peak Since you didn’t definie ‘width’, I used that value, since FWHM is the most commonly-used metric.
It may be difficult to determine with any accuracy where a peak begins and ends, as it is here as well, if you look at the data. There are several consecutive zero values at both minima near 250 and 425. Does the peak begin at the position of the first zero or the last in the blue portion of the curve, and similarly does it end at the first or last zero in the red pottion of the curve? The FWHM value is much easier to determine.
It calculates the maximum as ‘999’, the result of the max function, in order to get the ‘yq’ (half-maximum) value. It just doesn’t specifically report it.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







