用imhist函数来计算和显示图象的直方图。
代码clc; clear all; close all;I = imread('football.jpg');figure;subplot(1, 3, 1); imhist(I(:, :, 1)); title('R直方图');subplot(1, 3, 2); imhist(I(:, :, 2)); title('G直方图');subplot(1, 3, 3); imhist(I(:, :, 3)); title('B直方图');结果