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개)

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 CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by