From: Ravi Rastogi on
Hi Everyone,

For my application i need to find out the Local Maxima and Minima of the any 1D data.
Here are the steps:
1) Load the data; (Bx)
please email me and i will send you the data.

2) Determine the possible no of scales.

%%Determining the maximum scale:
for p=1:20
if((2^p)<=(length(Bx)/2))
maxscl=2^p;
elseif((2^p)>=(Bx/2))
break;
end
end;

3) Determine continuous wavelet transform coefficients for all the possible scales

%%Continuous Wavelet Transform:
scale=1:maxscl;
space=1:length(Bx);
figure;
r=cwt(Bx,scale,'db10','plot');

4) Use the Localmax function of wavelet toolbox to find and plot all the Local Maxima
plots.

%%Determining Local Maximum of a MATRIX:
local_max_coef = localmax(r);
[Rows, Cols]= find(local_max_coef);
%Plot the maxima
figure;
plot(space(Cols),scale(Rows), ...
'marker','*', ...
'markersize',2, ...
'linestyle','none', ...
'color','k');

5) Then i use a function called peakdet.m ( http://www.billauer.co.il/peakdet.html ) to determine the local max and minima points.

%%Plotting scale space plot of maxima and minima
max_r(scale,space)=0;
min_r(scale,space)=0;
for scl=1:maxscl
[maxtab, mintab]=peakdet(r(scl,:), 1); % Determining maxima and minima
maxpos=round(maxtab(:,1)); %position of maxima in space
max_r(scl,maxpos)=1;
minpos=round(mintab(:,1));
min_r(scl,minpos)=1;
end;

%Plotting it:
figure;
imshow(~max_r);
title('Maxima Plot')
figure;
imshow(~min_r);
title('Minima Plot')

PROBLEM: I want get a plot similar to step 4, but am not sure what is the best way to do it? so i tried out it in matrix and plotting the image, but since the matrix starts from (0,0) on the top left the whole plot looks inverted. Can someone suggest me a better way of plotting the data??

Thanks,
Ravi
From: Wayne King on
"Ravi Rastogi" <raviras(a)gmail.com> wrote in message <hmoq29$d07$1(a)fred.mathworks.com>...
> Hi Everyone,
>
> For my application i need to find out the Local Maxima and Minima of the any 1D data.
> Here are the steps:
> 1) Load the data; (Bx)
> please email me and i will send you the data.
>
> 2) Determine the possible no of scales.
>
> %%Determining the maximum scale:
> for p=1:20
> if((2^p)<=(length(Bx)/2))
> maxscl=2^p;
> elseif((2^p)>=(Bx/2))
> break;
> end
> end;
>
> 3) Determine continuous wavelet transform coefficients for all the possible scales
>
> %%Continuous Wavelet Transform:
> scale=1:maxscl;
> space=1:length(Bx);
> figure;
> r=cwt(Bx,scale,'db10','plot');
>
> 4) Use the Localmax function of wavelet toolbox to find and plot all the Local Maxima
> plots.
>
> %%Determining Local Maximum of a MATRIX:
> local_max_coef = localmax(r);
> [Rows, Cols]= find(local_max_coef);
> %Plot the maxima
> figure;
> plot(space(Cols),scale(Rows), ...
> 'marker','*', ...
> 'markersize',2, ...
> 'linestyle','none', ...
> 'color','k');
>
> 5) Then i use a function called peakdet.m ( http://www.billauer.co.il/peakdet.html ) to determine the local max and minima points.
>
> %%Plotting scale space plot of maxima and minima
> max_r(scale,space)=0;
> min_r(scale,space)=0;
> for scl=1:maxscl
> [maxtab, mintab]=peakdet(r(scl,:), 1); % Determining maxima and minima
> maxpos=round(maxtab(:,1)); %position of maxima in space
> max_r(scl,maxpos)=1;
> minpos=round(mintab(:,1));
> min_r(scl,minpos)=1;
> end;
>
> %Plotting it:
> figure;
> imshow(~max_r);
> title('Maxima Plot')
> figure;
> imshow(~min_r);
> title('Minima Plot')
>
> PROBLEM: I want get a plot similar to step 4, but am not sure what is the best way to do it? so i tried out it in matrix and plotting the image, but since the matrix starts from (0,0) on the top left the whole plot looks inverted. Can someone suggest me a better way of plotting the data??
>
> Thanks,
> Ravi

Hi Ravi, if the inverted nature of the plot is what is bothering you, how about just issuing

axis xy

that moves the origin to the lower left corner. Does that get at what you need?

Wayne
From: Ravi Rastogi on
> Hi Ravi, if the inverted nature of the plot is what is bothering you, how about just issuing
>
> axis xy
>
> that moves the origin to the lower left corner. Does that get at what you need?
>
> Wayne

Hi Wayne,

Thanks for your reply.
I email you the data file so that you can see what i am talking about. When you run the step4, the plot has x and y tick marks, that way i can tell at what scale the discontinuities are. But when i try to do the same for max_r and min_r matrix, i don't get a similar plot. I need a similar plot to look at the discontinuities of local minima also.


Ravi
From: Wayne King on
"Ravi Rastogi" <raviras(a)gmail.com> wrote in message <hmp3q4$jkd$1(a)fred.mathworks.com>...
> > Hi Ravi, if the inverted nature of the plot is what is bothering you, how about just issuing
> >
> > axis xy
> >
> > that moves the origin to the lower left corner. Does that get at what you need?
> >
> > Wayne
>
> Hi Wayne,
>
> Thanks for your reply.
> I email you the data file so that you can see what i am talking about. When you run the step4, the plot has x and y tick marks, that way i can tell at what scale the discontinuities are. But when i try to do the same for max_r and min_r matrix, i don't get a similar plot. I need a similar plot to look at the discontinuities of local minima also.
>
>
> Ravi

Hi Ravi, if you want tick labels while using imshow(), then do

iptsetpref('ImshowAxesVisible','on')
imshow(~min_r)
axis xy

Hope that helps,
Wayne
From: Ravi Rastogi on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hmp66s$p6k$1(a)fred.mathworks.com>...
> "Ravi Rastogi" <raviras(a)gmail.com> wrote in message <hmp3q4$jkd$1(a)fred.mathworks.com>...
> > > Hi Ravi, if the inverted nature of the plot is what is bothering you, how about just issuing
> > >
> > > axis xy
> > >
> > > that moves the origin to the lower left corner. Does that get at what you need?
> > >
> > > Wayne
> >
> > Hi Wayne,
> >
> > Thanks for your reply.
> > I email you the data file so that you can see what i am talking about. When you run the step4, the plot has x and y tick marks, that way i can tell at what scale the discontinuities are. But when i try to do the same for max_r and min_r matrix, i don't get a similar plot. I need a similar plot to look at the discontinuities of local minima also.
> >
> >
> > Ravi
>
> Hi Ravi, if you want tick labels while using imshow(), then do
>
> iptsetpref('ImshowAxesVisible','on')
> imshow(~min_r)
> axis xy
>
> Hope that helps,
> Wayne

Hi Wayne,

Great!! This works ...:-)
Thanks a lot

Ravi