Help with Pixel intensity histogram and export
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Image Analyst
le 5 Juin 2014
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).
0 commentaires
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!