子函数function [n]=calculate_histogram(PS, nBins)
% img gray scale image ranging from [0, 255]
% nBins number of the histogram bins
% output histogram vector
img=imread(PS);
n=imhist(img,nBins);% 直方图的结果是一个向量,每一位对应一个统计数值,相应灰度值的像素个数直接访问就好了
子函数的调用
[n]=calculate_histogram('C:\Users\Administrator\Desktop\新建文件夹\brightness and contrast\gaoyuanyuan.jpg',100);n
错误
Undefined function 'calculate_histogram' for input arguments of type 'char'.