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

1 次查看(过去 30 天)
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

回答(1 个)

Yuvaraj Venkataswamy

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by