How to Convert A Matrix Into a Custom Binned Histogram (Histogram of Variance Value)
3 ビュー (過去 30 日間)
古いコメントを表示
Although I'm rather new to MATLAB scripting, I tried to search around before posing this question and could not seem to find any help regarding trying to plot a histogram of the variance value from my 10,000 X 10,000 array.
For example, all the pixels in this array contain values ranging from 0-255 and I would like to make a histogram showing how many of these pixels have a value between x-y, then between y-z, etc and divide the WHOLE range into at least 100 bins. More specifically, if one was looking at the final scaled plot, the range would be 0-255, where there is a bin every increment of 10: 0-<10, 10-<20, 20-<30, etc. The bin values would be on the X-axis and the # of pixels falling into each bin would be on the Y-axis.
Any help or pointers would be GREATLY appreciated!
Thanks
-Reid
0 件のコメント
採用された回答
Andrew Sykes
2014 年 3 月 31 日
This might help. Assume "A" is your 10,000 X 10,000 array (preset in this example by random numbers, so ignore the first line of this code if you like).
A=rand(1e4,1e4)*255;
Avec=reshape(A,1e4*1e4,1);
bin_increment=10;
NumberOfBins=ceil(255/bin_increment);
hist(A,NumberOfBins)
This code should produce a figure with the histogram you want. Alternatively, you may wish to actually store the histogram data:
BinPopulations=hist(A,NumberOfBins)
This will generate a vector telling you how many pixels are in each bin.
HTH.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!