How to retrieve data points from a grayscale histogram?

6 次查看(过去 30 天)
Hello! I have a grayscale image and its histogram. How do can I extract data points from this histogram? Say, the number of pixels for each value of the grayscale; I need to put that information into excel.
Thank you.

采纳的回答

Image Analyst
Image Analyst 2021-6-12
Try this:
grayImage = imread('cameraman.tif'); % Read in image.
counts = imhist(grayImage) % Take histogram
grayLevels = 0 : (length(counts) - 1) % Construct gray level vector.
dataForExcel = [grayLevels(:), counts] % Stitch them together into one array.
writematrix(dataForExcel, 'data.xlsx'); % Write an Excel workbook.

更多回答(1 个)

Sulaymon Eshkabilov
(1) Import// read your image in matlab
(2) perform histogram analysis with hostogram(), e.g: h= histogram() or h = histogram2()
(3) Collect necessary data from h that would be a structure array containing all data.

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by