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

Click For Summary

Discussion Overview

The discussion revolves around determining the area under a plot generated from histograms of images using MATLAB. Participants explore the steps involved in plotting histograms, approximating curves, and calculating areas, with a focus on the correct methods to achieve these tasks.

Discussion Character

  • Technical explanation, Homework-related, Mathematical reasoning

Main Points Raised

  • One participant outlines a series of steps for a project involving image analysis, including plotting histograms and determining areas under curves.
  • Another participant suggests using the MATLAB command 'trapz' for calculating the area under a continuous plot.
  • A question is raised about whether to apply 'trapz' directly to the histogram or to the plot of the histogram, indicating uncertainty about the correct approach.
  • Further clarification is provided that 'trapz' should be applied to the histogram data rather than the plot of the histogram, with a suggestion that the area under the peaks is of interest.

Areas of Agreement / Disagreement

There is no clear consensus on the best method to calculate the area under the curve, as participants express differing views on whether to use the histogram data or the plotted curve.

Contextual Notes

Participants express uncertainty regarding the continuity of the plot and the appropriateness of using 'trapz' for different representations of the histogram data.

Who May Find This Useful

Individuals working on image analysis projects using MATLAB, particularly those interested in histogram analysis and area calculations.

maverick280857
Messages
1,774
Reaction score
5
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:
Physics news on Phys.org
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))
 
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...
 
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 that's 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.
 
Thanks
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 14 ·
Replies
14
Views
4K