1

Profile

I have extracted profile on cross-section of vessel by following code

 imshow(image); % image is not shown
 [cx,cy,c,xi,yi] = improfile;

Here c is the intensity along the profile and I plot them using:

 x=1:length(c);
 figure
 plot(x,c,'o')
 axis([0 45 80 150])

and it look like the one I have uploaded. c is 33X1 intensity vector where, c=[123 126 131 138 139 141 143 143 144 141 136 126 102 96 91 100 100 113 109 96 94 90 101 107 116 123 127 130 131 132 131 129 131];

I want to detect index of c to find A (max in left side),B (max in right side),C (min in left side), D(min in rt side) and E (middle) points in the profile.

Dev
  • 329
  • 10
  • 21

1 Answers1

1

The function peakdet released in the public domain (http://www.billauer.co.il/peakdet.html) seems to do the job on the first try. You can try to play with the second parameter of the function to be more / less selective.

c=[123 126 131 138 139 141 143 143 144 141 136 126 102 96 91 100 100 113 109 96 94 90 101 107 116 123 127 130 131 132 131 129 131];
[ma mi]=peakdet(c,1);

ma =
     9   144
    18   113
    30   132

mi =
    15    91
    22    90
    32   129

EDIT: this question could be of interest: How to differentiate between a double peak and a single peak array in MATLAB?

Community
  • 1
  • 1
Aabaz
  • 3,106
  • 2
  • 21
  • 26
  • Thank you for your reply. It worked, but for delta=2 as you did, it calculate 3 minimum points (extra min at index 32 ) which is not required in my case but with delta =2 it gives me answer with 3 max. and 2 min. as required. Is there any way to adjust the threshold automatically as I have to process around 100s of data of such pattern and adjusting delta for each kind is time consuming and it is not possible to adjust manually every time. – Dev Feb 07 '13 at 11:45
  • If you know that all your datasets have the same look / shape, then you could try to use this function multiple times until it finds the right number of local extrema. Although maybe this is not optimal and other algorithm exist that are better suited for your particular datasets, this should still work. – Aabaz Feb 07 '13 at 12:08