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에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!