说我有一些image,我找到了histogram。还说我有一些equation我想为直方图中的每个元素计算。如何沿直方图值移动MATLAB?
我做了以下事情:
I=imread('xyz.jpg');
h=imhist(I);
h(1) % get the value of the first element
这样,为了应用我的等式,我使用h(1)了 value 例如。
是这样吗?
谢谢。
如果你想迭代直方图值,我建议你提取两个输出imhist(我冒昧地给它们提供更具表现力的变量名称):
[counts, bins] = imhist(I);
数组bins和counts分别包含直方图 bin 位置及其计数。然后你可以使用 for 循环:
res = zeros(numel(counts), 1); %// Preallocate array for the result
for k = 1:numel(counts)
%// Apply equation on counts(k) and bins(k), for example:
res(k) = some_equation(bins(k), counts(k));
end
或者如果可能的话,以矢量化形式应用方程。