我已经有了这个:
function [h] = histImage (img)
nPix = numel(img);
h = accumarray( img (:)+1 , ones(nPix,1)/nPix, [256 1] , @sum,0)
this function will return a grayscale histogram for a given img into a 1X256 vector
now i want to build this function:
input: img - grayscale image matrix in rage [0..255]
windowSize - a 1x2 array [r c] rows and cols.
output: histArray 3d matrix for every i,j the 1D array histArray(i,j,:) is the histogram of img of the size WindowSize whose top left corner is (i,j)
function [histArray] = localHistograms (img,windowSize)
histArray = zeros(windowSize(1),WindowSize(2),256);
for i = 1:windowSize(1)
for j = 1:windowSize(2)
histArray(i,j,:) = histImage(img( i:windowSize(1), j:windowSize(2) ))
end
end
end
这是我到目前为止所拥有的,你能告诉我我的错误吗?我如何检查我的错误?只需输入一些随机图像?