From: leila on 9 May 2010 02:11 how to extract mean from histogram
From: us on 9 May 2010 07:40 leila <leeeila12345(a)live.fr> wrote in message <1094829207.97470.1273399915282.JavaMail.root(a)gallium.mathforum.org>... > how to extract mean from histogram a hint: help mean; us
From: Rune Allnor on 9 May 2010 07:45 On 9 Mai, 12:11, leila <leeeila12...(a)live.fr> wrote: > how to extract mean from histogram You can *estimate* the mean by using the bin counts and the bin widths and insert in the (discretized) integral formula for the mean. The estimate will be more or less good, depending on the distribution of samples inside each bin interval. Rune
From: ImageAnalyst on 9 May 2010 08:14 On May 9, 6:11 am, leila <leeeila12...(a)live.fr> wrote: > how to extract mean from histogram ------------------------------------------------------------------------------------------- leila: I assume you mean the average gray level. Well it's the standard mean formula that's in the textbooks: meanX = sum(y .* x) / sum(x); or: meanGL = sum(pixelCount .* grayLevels) / sum(pixelCount); as in this demo: grayImage = imread('cameraman.tif'); subplot(1, 2, 1); imshow(grayImage, []); title('Original Grayscale Image'); set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen. % Let's get its histogram. [pixelCount grayLevels] = imhist(grayImage); subplot(1, 2, 2); bar(pixelCount); title('Histogram of original image'); xlim([0 grayLevels(end)]); % Scale x axis manually. yRange = ylim; % Calculate the mean gray level meanGL = sum(pixelCount .* grayLevels) / sum(pixelCount); meanBinHeight = mean(pixelCount); line([meanGL meanGL], yRange); message = sprintf('The mean gray level is %6.2f', meanGL); text(meanGL+5, 0.8*yRange(2), message); message = sprintf('Done!\nThe mean gray level is %6.2f\nThe mean bin height = %.2f', ... meanGL, meanBinHeight); msgbox(message);
|
Pages: 1 Prev: Instrument Control Toolbox and Simmechanics Next: Problem-counting people |