haazo.blogg.se

Matlab histogram
Matlab histogram






matlab histogram

Therefore, you must convert to some type that extends beyond the limits of uint8 and then you add by 1 to avoid saturation. When we get to the most extreme case of value 255 for type uint8 for example, adding 1 to this using the native uint8 will saturate to 255, which means that the values of 254 and 255 get lumped into the same bin. In MATLAB, we index into rows and columns of a matrix starting at 1 and because the values will potentially start at value 0, this corresponds to row 1 of your histogram so you have to offset by 1. Because your input is type uint8, any values beyond 255 will saturate to 255.

matlab histogram

This means that any values that are beyond the dynamic range of the type will get saturated. The last question you have is why cast the intensity to double and add 1? You cast to double because the input may be an integer type. M(i,j) is the value found at location (i,j) in your 2D data. Therefore, the line is simply just accessing the current count and adding 1 to it. Note that the counts are all initialized to zero, so the logic is that every time you see a value, you need to access the right row corresponding to the data point, then increment that value by 1.

matlab histogram

Therefore, each row tells you which value you are examining in your data as well as how many times you have seen that value in your data. In this case, you have a two column matrix where the first column tells you the value you want to examine and the second column tells you how many times you see that value in your data. Recall that a histogram records the total number of times you see a value. Judging by your initialization of the histogram, there are 256 possible values so your input is most likely of type uint8, which means that the values in your data will only be from in steps of 1. Note: Your initialization of your histogram L has the brackets mismatched.








Matlab histogram