MATLAB: How to compare the value of a pixel with all other pixel

compare

i have to compare each pixel with all other pixels and find equal values.

Best Answer

M = randi(10,40,30);
uM = unique(M);
out = [uM, histc(M(:),uM)];