% 通过程序获取灰度图像的直方图
% 编写时间:2017-11-24 19:36:11 编写人:gq
close all; clear all; clc;
orgin_image = imread('pout.tif');
row = size(orgin_image, 1); % 行
column = size(orgin_image, 2); %列
N = zeros(1, 256); % N是1*256的行向量
for i = 1:row
for j = 1:column
k = orgin_image(i, j);
N(k+1) = N(k+1) + 1;
end
end
subplot(121), imshow(orgin_image);
subplot(122), bar(N); %绘制直方图
axis tight; % 使坐标系的最大值和最小值和你的数据范围一致。
% 通过程序获取灰度图像的直方图
% 编写时间:2017-11-24 19:36:11 编写