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.
댓글 수: 0
채택된 답변
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
2021년 6월 12일
(1) Import// read your image in matlab
(2) perform histogram analysis with hostogram(), e.g: h= histogram() or h = histogram2()
See this doc: https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram2.html
(3) Collect necessary data from h that would be a structure array containing all data.
댓글 수: 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!