Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report