obtaining magnitude of histogram plot

5 ビュー (過去 30 日間)
divya r
divya r 2012 年 7 月 25 日
回答済み: Kanishk 2025 年 7 月 3 日 9:01
I have plot the histogram of an image using imhist() function. I want to obtain the magnitude of the histogram plot. imhist() returns 2 arguments : counts and x.
img=imread('C:\Users\Divya\Desktop\1_2_1.bmp');
img1=rgb2gray(img);
[counts x]=imhist(img1,20000);
counts and x both are 20000*1 array. It does not provide information about the whole image
Any pointers on how i can obtain this data?

回答 (1 件)

Kanishk
Kanishk 2025 年 7 月 3 日 9:01
Hello Divya,
The histogram does describe the whole image, just not spatially. You can compute the magnitude (total pixel count per bin):
total_pixels = sum(counts);
If by "magnitude" you mean the peak value:
max_count = max(counts);
If you want to normalize the Histogram to get probability instead of raw counts:
normalized_counts = counts / sum(counts);
If you want to view Basic Image Summary: (e.g., min, max, mean intensity):
stats.min_val = min(img1(:));
stats.max_val = max(img1(:));
stats.mean_val = mean(img1(:));
stats.std_val = std(double(img1(:)));
Hope this helps!!

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by