Help with Pixel intensity histogram and export

3 ビュー (過去 30 日間)
Chris
Chris 2014 年 6 月 5 日
回答済み: Image Analyst 2014 年 6 月 5 日
Hi everyone,
So I have a gray image, and I have created a matrix of the pixel intensity values. I then plotted these on a histogram to see the frequency of certain pixel intensities. Right now, I'm having trouble with two things:
  • How do I export this data, getting the "bin" sizes from the x axis and the frequency on the y axis?
  • How can I fit the behavior of the "tops" of the histogram via a non-normal distribution (the shape I have is like 3 mountains).
Here is my code:
clc grid on; imagename = 'blah.jpg'; I=imread(imagename); K=rgb2gray(I); imshow(K); [x,y]=size(K); X=1:x; Y=1:y; [xx,yy]=meshgrid(Y,X); i=im2double(K)
figure;mesh(xx,yy,i);colorbar; figure;h=pcolor(i);set(h,'Edgecolor','none'); figure;imhist(i,256); %256 since the range of gray pixel is 0 to 255 [hh,xxx]=hist(i,256);
Thanks!
  1 件のコメント
Geoff Hayes
Geoff Hayes 2014 年 6 月 5 日
To get the histogram data, just do
[counts,x]=imhist();

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2014 年 6 月 5 日
You can use
[pixelCounts, grayLevels] = imhist(grayImage, 256);
bar(grayLevels, pixelCounts);
Not sure exactly what you mean by export but you can try fprintf(), save(), xlswrite(), writetable(), csvwrite(), dlmwrite(), etc.
Not sure how you want to fit 3 mountains. Maybe 3 Gaussians, maybe a 6th order polynomial (if the peaks are spaced evenly).

カテゴリ

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