Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the statistical chart of image luminance distribution with Matlab

Shulou Source: shulou.com Published: 2022-05-31 16:52:05 09月29日 Update

This article mainly explains "how to use Matlab to achieve image brightness distribution statistical map", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "how to use Matlab to achieve image luminance distribution statistical map"!

If you write an input image, it will generate a beautiful function of the brightness distribution of each channel of the image, and the effect is as follows:

As usual, the utility function comes first, and then I'll show you how to use it:

Tool function

Function HistogramPic (pic) FreqNum=zeros (size (pic,3), 256); for i=1:size (pic,3) for juni0pur255 FreqNum (iGrain1) = sum (pic (pic (:,:, I) = = j); endendax=gca;hold (ax,'on'); box on;grid onif size (FreqNum,1) = = 3 bar (0Rod 255FreqNum (1Coe:), 'FaceColor', [0.6350 0.0780 0.1840],' FaceAlpha',0.5) Bar, 'FaceColor', [0.2400 0.5300 0.0900],' FaceAlpha',0.5); bar, 'FaceColor', [0 0.4470 0.7410],' FaceAlpha',0.5); ax.XLabel.String='RGB brightness' Rrange= [num2str (min (pic (:,:, 1), [], [1Magne2])),',', num2str (max (pic (:,:, 1), [], [1jor2])]; grange= [num2str (min (pic (:,:, 2), [], [1j2])),',', num2str (max (pic (:,:, 2), [], [1J2]))]) Brange= [num2str (min (pic (:,:, 3), [], [1Magne2])),',', num2str (max (pic (:,:, 3), [], [1d2])]; legend ({['R: range [', rrange,']'], ['G: range [', grange,']'], ['B: range [', brange,']']},... 'Location','northwest','Color', [0.9412 0.9412 0.9412],... 'FontName','Cambria','LineWidth',0.8,'FontSize',11); else bar (0FaceColor', (1dre:),' FaceColor', [0.500.500.50], 'FaceAlpha',0.5); ax.XLabel.String='Gray scale'; krange= [num2str (min (pic (:,:, 1), [], [1Mague 2])),',', num2str (max (pic (:,:, 1), [], [1Jue 2]))] Legend (['Gray: range [', krange,']'],... 'Location','northwest','Color', [0.9412 0.9412 0.9412],... 'FontName','Cambria','LineWidth',0.8,'FontSize',11); endax.LineWidth=1;ax.GridLineStyle='--';ax.XLim= [- 5255]; ax.XTick= [0ax.XTick= 45purl 255255]; ax.YLabel.String='Frequency number';ax.FontName='Cambria';ax.FontSize=13;end

Function call

A very simple way to use it is to call the function after reading the image:

Pic=imread ('test.png'); HistogramPic (pic)

If the image is a color picture, the effect is as follows:

If the image is grayscale, the effect is as follows:

Thank you for your reading, the above is the content of "how to use Matlab to achieve image brightness distribution statistical map". After the study of this article, I believe you have a deeper understanding of how to use Matlab to achieve image brightness distribution statistical chart. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Images functions brightness statistics effects learning content pictures that is tools beauty usage distribution maps color maps ideas situations articles methods more appearance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei MySQL OPPO Reno vpn