MATLAB help: determining the area under a plot (not a curve whose form is known)

1,789
4

Main Question or Discussion Point

Hi

For a project (described https://www.physicsforums.com/showthread.php?t=227684"), I have to do the following for N images:

1. plot the histogram of each image, using

imhist(x)

2. plot a curvilinear approximation to the histogram, using

plot(imhist(x))

3. determine the area under the plot generated in step 2

4. Plot a curve of area value versus image number (index) and determine the image number for which the area value is a minimum.

I am not sure how to do step 3 and also whether steps 1 and 2 are correct.

Can someone please help?

Thanks and cheers
vivek
 
Last edited by a moderator:

Answers and Replies

243
1
If step 2 is continuous then try the MATLAB command 'trapz'.
Go:
help trapz
in the MATLAB command window. Hopefully you can do:
trapz(imhist(x))
 
1,789
4
Should I do

trapz(imhist(x))

or

trapz(plot(imhist(x))

?

plot(imhist(x)) plots the histogram with the peaks joined by a not-so-smooth curve...
 
243
1
You should do:
trapz(imhist(x))

Now you say that plot(imhist(x)) plots a histogram with peaks joined by a curve? I assume you want the area under that curve? If thats the case I don't think trapz will help - you need to JUST plot the peaks and trapz will give the area under that curve.
 
1,789
4
Thanks
 

Related Threads for: MATLAB help: determining the area under a plot (not a curve whose form is known)

Replies
5
Views
12K
Replies
5
Views
705
Replies
4
Views
6K
  • Last Post
Replies
2
Views
2K
Replies
4
Views
28K
  • Last Post
Replies
0
Views
1K
Replies
2
Views
9K
  • Last Post
Replies
3
Views
8K
Top