0


我正在使用Mathwork 网站上给出的Matlab 的场景变化检测示例。代码运行良好,直到最后一段显示以下错误:

使用错误 -
矩阵尺寸必须一致。场景变化中的错误(第 65 行)
edge_diff = abs(mean_blks - mean_blks_prev);

错误行是:

edge_diff = abs(mean_blks - mean_blks_prev);

我检查了尺寸。它们是:15 170 1
有人试过这个例子并得到这个错误吗?如何修复此错误?

4

1 回答 1

1

试试这个:

len_mean_blks      = length(mean_blks);
len_mean_blks_prev = length(mean_blks_prev);

if len_mean_blks < len_mean_blks_prev
    padded_mean_blks                  = nan(len_mean_blks_prev, 1);
    padded_mean_blks(1:len_mean_blks) = mean_blks;
    edge_diff = abs(padded_mean_blks - mean_blks_prev);
elseif len_mean_blks > len_mean_blks_prev 
    padded_mean_blks_prev                       = nan(len_mean_blks, 1);
    padded_mean_blks_prev(1:len_mean_blks_prev) = mean_blks_prev;
    edge_diff = abs(mean_blks - padded_mean_blks_prev);
end
于 2013-03-20T07:29:33.207 回答