Hey there
i was working on histogram. Article says "ith level of histogram" and that was unclear for me. I have an image and i want to code this formula but i cant because of it. Here is the formula(Th1 Th2 Th3 and Th4 are defined values like 15 50 ...) :
And article says this about h(i) is
Can u guys help me to code it.
Thank you

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Mär. 2017

0 Stimmen

Figure 2 (that you did not happen to show) apparently lists a series of threshold levels for histogramming. If you place those in a vector named "Levels", from smallest to largest (possibly with a leading 0), then the count of the values between Levels(i) and Levels(i+1) are what h(i) is. So for example,
h = histc(YourData, Levels)

7 Kommentare

Fabio Corres
Fabio Corres am 12 Mär. 2017
Here it is the figure 2
Walter Roberson
Walter Roberson am 12 Mär. 2017
When I look at the diagram it seems most likely that the "a histogram" that they talk about has been done as
h = histc(YourData, 0:255)
and visually you could use imhist() to see that.
Fabio Corres
Fabio Corres am 12 Mär. 2017
i want to understand the question. for example in first sunm of series is it represent the number 205 (Th3) ? and Hi shows the summation of this ?
Walter Roberson
Walter Roberson am 12 Mär. 2017
Hi_mask = Yourdata >= 205 & Yourdata < 240;
Hi = sum(Hi_mask(:));
Fabio Corres
Fabio Corres am 12 Mär. 2017
Bearbeitet: Fabio Corres am 12 Mär. 2017
but it counts the how many element in range.I want to sum their values
Walter Roberson
Walter Roberson am 12 Mär. 2017
Did you switch topics?
The formula you show sums histogram counts, not pixel values.
Summing histogram counts is equivalent to histogramming over wider bins, which is equivalent to counting the number that fall into the range of the bins.
For example if your values did no happen to exceed 3,
h(1) = sum( YourData == 0);
h(2) = sum( YourData == 1);
h(3) = sum( YourData == 2);
h(4) = sum( YourData == 3);
would be equivalent to
h = histc( YourData, [0 1 2 3]);
and Σ( i = 3 to 4, of h(i) ) would be h(3) + h(4), which would be equivalent to sum( YourData == 2 | YourData == 3) -- the total count of pixels values in the appropriate range.
Just watch out for whether the formula calls h(0) or h(1) the first entry.
Fabio Corres
Fabio Corres am 13 Mär. 2017
Oh i understand my mistake thank you it works

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by