Effacer les filtres
Effacer les filtres

How can get all the maximum and minimous values of peaks and valleys in a vector?

1 vue (au cours des 30 derniers jours)
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
Thank you very much for your suport

Réponses (1)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy le 7 Mai 2018

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by