【问题标题】:Shifting along the range of histogram values沿直方图值范围移动
【发布时间】:2013-09-08 00:54:45
【问题描述】:

假设我有一些image,为此我找到了histogram。还说我有一些equation,我想为直方图中的每个元素计算。如何沿MATLAB 中的直方图值移动?

我做了以下事情:

I=imread('xyz.jpg');
h=imhist(I);
h(1) % get the value of the first element

这样,为了应用我的等式,我使用了h(1) 值。

是这样吗?

谢谢。

【问题讨论】:

    标签: matlab histogram shift


    【解决方案1】:

    如果您想迭代直方图值,我建议您提取imhist 的两个输出(我冒昧地给它们赋予更具表现力的变量名称):

    [counts, bins] = imhist(I);
    

    数组 binscounts 分别包含直方图 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
    

    如果可能,或者以矢量化形式应用方程。

    【讨论】:

      猜你喜欢
      • 2019-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 2017-10-24
      • 1970-01-01
      相关资源
      最近更新 更多