% 假设已存在单通道图像imgh = imhist(img); % 求直方图N = nnz(h); % 非零灰阶数h = nonzeros(h); % 剔除非零元素pmax = max(h); % 最大点数(我理解为直方图的峰值)pmin = min(h); % 最小点数(理解类似上面)ratio = pmax / pmin; % 比例