How can get all the maximum and minimous values of peaks and valleys in a vector?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In the following code I'm trying to get the maximus and minimous of the graphic; I don't want to use max(i) because that would give me only the higher maximum point and I want the values of every peak and valley The code is shown next:
%close everything and clear everything
close all;
clear all;
clc;
% First we read an image wich must contain a graphic in it and then convert it to black and white
A=im2bw(imread('prueba3.png'));
%Show the image
figure();
imshow(A);
%Obtain the rows and columns
[F,U]=size(A);
i=1;
%Then we "sweep" the matrix looking for the black pixels defined by a 0 and save the
%position "(m,n)" in the vector "x" and "y"
for n=1:U;
for m=1:F;
if A(m,n)~=1;
x(i)=n;
y(i)=m;
else
m=m+1;
end
end
n=n+1;
i=i+1;
end
figure();
plot(x,y);
set(gca, 'YDir', 'reverse')
How can I get the positions of maximus and minimous?
I'm using this image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190361/image.png)
Thank you very much for your suport
0 commentaires
Réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!