COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Locate Minima & Maxima

• Follow

```I am working on a project of calculating edge width in an image. I have to scan every row in the image to calculate the edge width. In order to do so, I need to detect several local minima and maxima for each row. An edge exists in between a local maxima and minima. There might be a few edges in one row. Any idea how to detect the local minima and maxima?
```
 0

```"Avengeline "
> I am working on a project of calculating edge width in an image. I have to scan every row in the image to calculate the edge width. In order to do so, I need to detect several local minima and maxima for each row. An edge exists in between a local maxima and minima. There might be a few edges in one row. Any idea how to detect the local minima and maxima?
Help min,max (or nanmin/nanmax). Pay attention to the dim argument.

Oleg
```
 0
Reply oleg.komarov (127) 1/13/2010 2:05:21 PM

```On Jan 6, 5:45=A0am, "Avengeline " <avengeline....@gmail.com> wrote:
> I am working on a project of calculating edge width in an image. I have t=
o scan every row in the image to calculate the edge width. In order to do s=
o, I need to detect several local minima and maxima for each row. An edge e=
xists in between a local maxima and minima. There might be a few edges in o=
ne row. Any idea how to detect the local minima and maxima?

If x(i) =3D max(x(i-1:i+1)) is a start. However, you still
have to deal with x(i) =3D x(i-1) and/or x(i) =3D x(i+1).

Similarly with min.

Hope this helps.

Greg
```
 0
Reply heath (3882) 1/14/2010 4:40:09 AM

```Greg Heath <heath@alumni.brown.edu> wrote in message <6ff94dab-0022-4f8b-86c7-96c931657d20@b2g2000yqi.googlegroups.com>...
> On Jan 6, 5:45 am, "Avengeline " <avengeline....@gmail.com> wrote:
> > I am working on a project of calculating edge width in an image. I have to scan every row in the image to calculate the edge width. In order to do so, I need to detect several local minima and maxima for each row. An edge exists in between a local maxima and minima. There might be a few edges in one row. Any idea how to detect the local minima and maxima?
>
> If x(i) = max(x(i-1:i+1)) is a start. However, you still
> have to deal with x(i) = x(i-1) and/or x(i) = x(i+1).
>
> Similarly with min.
>
> Hope this helps.
>
> Greg

I still can't detect the local minima & maxima through the edge coordinates I obtained. Example, in one row of the image (let's say row = 200), 3 positions of edges are found after edge detection; which are [200 60], [200 155] and [200 240]. Assuming the image is 240 x 240 pixels. So from these coordinates, I have to determine the local minima and maxima for each coordinates based on the graph I plotted for row = 200 of a grayscale image. I am basically stuck here. Any idea?
```
 0

```On Jan 24, 10:48=A0am, "Avengeline " <avengeline....@gmail.com> wrote:
> I still can't detect the local minima & maxima through the edge coordinat=
es I obtained. Example, in one row of the image (let's say row =3D 200), 3 =
positions of edges are found after edge detection; which are [200 60], [200=
155] and [200 240]. Assuming the image is 240 x 240 pixels. So from these =
coordinates, I have to determine the local minima and maxima for each coord=
inates based on the graph I plotted for row =3D 200 of a grayscale image. I=
am basically stuck here. Any idea?
---------------------------------------------------------------------------=
-----------------------------
Avangeline:
You're not describing what you want accurately/specifically enough.
You say you have the positions of the edges.  Well the max or min is
simply the value of your edge image at those points.  Fore example at
[200,60] it would be edgeImage(200, 60) - simple as that.  Because
getting the value of an array at a row,column location is so trivially
obvious, I'm not really sure if this is what you meant.  So please
explain better.

If you need help locating the max values in the edge image, you can
use imregionalmax().

Make sure you're using the continuous edge image rather than one
that's already been binarized.  For example, use imfilter() rather
than edge() or else you won't know the underlying edge strength
values.

clc;
close all;
clear all;
workspace; % Display workspace panel.
% Read in standard MATLAB demo image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

edgeImage =3D imfilter(grayImage,fspecial('sobel') /8,'replicate');
subplot(2, 2, 2);
imshow(edgeImage, []);
title('Edge Image');

peakEdges =3D imregionalmax(edgeImage, 8);
subplot(2, 2, 3);
imshow(peakEdges, []);
title('Local Peak (Max) Edges');

minEdgeStrength =3D 15;
strongEdges =3D edgeImage > minEdgeStrength;
subplot(2, 2, 4);
imshow(strongEdges, []);
title('Strong Edges');

Good luck,
ImageAnalyst

```
 0

```"Avengeline " <avengeline.biz@gmail.com> wrote in message <hi1pk4\$p51\$1@fred.mathworks.com>...
> I am working on a project of calculating edge width in an image. I have to scan every row in the image to calculate the edge width. In order to do so, I need to detect several local minima and maxima for each row. An edge exists in between a local maxima and minima. There might be a few edges in one row. Any idea how to detect the local minima and maxima?

Hi
You can use my programs maxima and minima on the matlab file exchange library.
Good Luck
Aasim Azooz
```
 0

```I am sorry for all the confusion.

I uploaded the graph for 'a row of image, which is row = 240' here: http://farm5.static.flickr.com/4062/4302374885_0e70709e00_b.jpg

y-axis = pixel value
x-axis = pixel position (column)

I managed to obtain the coordinates through edge detection. In the graph. 2 edge locations are detected at [240, 22] - Y and [240, 80] - X.

I have problem to detect local maximas and local minimas (P1, P2, P3, P4) of the edge locations (X and Y). For example, the local maxima for an edge at X is P2 and local minima is P1.

Anyone can help?
```
 0

```I saw from a journal paper mentioning about a difference filter like local maximum filter/local minimum filter to detect the local maxima/minima. Does the filter exist in the Matlab library?
```
 0

```Avengeline :
Did you not see my earlier reply?
I said you can use imregionalmax() in the Image Processing Toolbox.
"BW = imregionalmin(I) computes the regional minima of I. The output
binary image BW has value 1 corresponding to the pixels of I that
belong to regional minima and 0 otherwise. BW is the same size as I.

Regional minima are connected components of pixels with a constant
intensity value, and whose external boundary pixels all have a higher
value. "

You can use imregionalmin() to find the local minima.
Alternatively you can use the findpeaks() function in the Signal
Processing Toolbox, or use similar functions people have uploaded to
the File Exchange.
"pks = findpeaks(data)finds local maxima or peaks pks in the input
data. data must be a row or column vector with real-valued elements
and have a minimum length of three. findpeaks compares each element of
data to its neighboring values. If an element of data is larger than
both of its neighbors, it is a local peak. If there are no local
maxima, pks is an empty vector."

Let me know if you've seen this reply.
```
 0

```ImageAnalyst <imageanalyst@mailinator.com> wrote in message <673c91de-3ff0-4513-b5c6-8e5b44216873@q4g2000yqm.googlegroups.com>...
> Avengeline :
> Did you not see my earlier reply?
> I said you can use imregionalmax() in the Image Processing Toolbox.
> "BW = imregionalmin(I) computes the regional minima of I. The output
> binary image BW has value 1 corresponding to the pixels of I that
> belong to regional minima and 0 otherwise. BW is the same size as I.
>
> Regional minima are connected components of pixels with a constant
> intensity value, and whose external boundary pixels all have a higher
> value. "
>
> You can use imregionalmin() to find the local minima.
> Alternatively you can use the findpeaks() function in the Signal
> Processing Toolbox, or use similar functions people have uploaded to
> the File Exchange.
> "pks = findpeaks(data)finds local maxima or peaks pks in the input
> data. data must be a row or column vector with real-valued elements
> and have a minimum length of three. findpeaks compares each element of
> data to its neighboring values. If an element of data is larger than
> both of its neighbors, it is a local peak. If there are no local
> maxima, pks is an empty vector."
>
>
> Let me know if you've seen this reply.

Hi. Thanks a lot for the reply. I will try to work it out first based on the information your provided. Willl update on this again.
```
 0

```Dear ImageAnalyst,

I got the all the local minimas already. Do you have any idea how to find the closest minima value to a point, X? Thanks.

Avengeline.
```
 0

```On Jan 26, 12:30=A0am, "Avengeline " <avengeline....@gmail.com> wrote:
> Dear ImageAnalyst,
>
> =A0 =A0I got the all the local minimas already. Do you have any idea how =
to find the closest minima value to a point, X? Thanks.
>
> Avengeline.

-----------------------------------------------------------------
Just take the absolute value of the difference in the index (element)
values at which they occur.  The smallest difference (delta x) will be
with the closest min.
```
 0

```Hi ImageAnalyst,

Can I also use imregionalmax to find local maxima? What is the difference between maxima and local maxima?
```
 0
Reply avengeline.biz (12) 1/31/2010 3:37:05 AM

```You can use imregionalmin to find local min.  Local min are min in one
small area.  You could have a local min that is not the global min.
You can have more than one local min and more than one global min if
they have the same value but are physically separated.
```
 0
Reply imageanalyst (7596) 1/31/2010 4:08:31 AM

```ImageAnalyst <imageanalyst@mailinator.com> wrote in message <de75006f-dd32-45cf-972e-7425131f3ea4@n7g2000yqb.googlegroups.com>...
> You can use imregionalmin to find local min.  Local min are min in one
> small area.  You could have a local min that is not the global min.
> You can have more than one local min and more than one global min if
> they have the same value but are physically separated.

Hi. I am trying to develop peak finding alogrithm. My focus of my project is not on this part but it is needed for data transformation.

I tried using SignalProcessing Toolbox and codes downloaded. All of them are able to locate the peaks using different techniques. Beside the peak amp and locations, I need to know the width.

Can anyone guide me to use SignalProcessing Toolbox to determine the width. I tried using the downloaded codes but their approaches cannot fit all shapes of peaks from my data. From my data, there are shape peak and broaden peak. Hence, is anyone able to guide me on using SignalProcessing Toolbox to solve my problem or any alternative? Thank you
```
 0

14 Replies
492 Views

Similiar Articles:

7/15/2012 1:30:00 PM