0
votes

Simply put I have an N x M matrix and I would like to obtain a 256 bin histogram for each column of the matrix. I know how to do this with a for loop, but I need to do it in matrix notation to save valuable computation time.

Also, I would like to use imhist rather than hist.

For loop method:

data = randint(100,100,10);

for n = 1:100

k(:,n) = imhist(data(n,:));

end

1

1 Answers

0
votes

hist operates on the column of the input matrix by default. So

>> k = hist( data, 0:255 ); 

should do the trick for you.