【问题标题】:Sliding Window over image results in 'out of memory or dimension too large for Octave's index type'在图像上滑动窗口会导致“内存不足或尺寸对于 Octave 的索引类型而言太大”
【发布时间】:2017-09-15 04:40:12
【问题描述】:

当我在图像上运行 mode 时出现错误:

错误:内存不足或尺寸对于 Octave 的索引类型来说太大
错误:从
调用 im2col 在第 134 行第 13 列
nlfilter 在第 79 行第 8 列
colour_blocks 在第 11 行第 7 列

这到底是什么问题,我能做些什么来克服这个问题?是不是我对图像的迭代效率低下?目标是在图像上创建一个滑动窗口 (256x256) 并计算每个窗口中最常见的颜色。

pkg load image;
pkg load signal;

% the image is quite small 400x400px
i = uint32(imread('foo.jpg'));


% encode 3 channel image into single channel
ienc = 1+bitor(bitor(i(:,:,1), bitshift(i(:,:,2),8)), bitshift(i(:,:,3),16));

% find the mode
imode = nlfilter(ienc, [256 256], @(x) mode(x(x~=0)));

【问题讨论】:

    标签: octave


    【解决方案1】:

    是的,问题是你的滑动窗口太大了。看看nlfilter source code

    256*256 窗口意味着每个窗口都有65536 元素。如果您的图像是 1024*1024,您将有 6.8719e+10 个视图,但您的 Octave(使用 32 位索引构建)无法处理超过 2147483647 个元素的数组。此外,如果您的图像是 double 类,则视图将占用大约 550GB 内存。

    【讨论】:

      猜你喜欢
      • 2022-06-19
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多