使用bsxfun MATLAB内存不足 [英] Out of Memory using bsxfun MATLAB

查看:261
本文介绍了使用bsxfun MATLAB内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Burrows-Wheeler变换实现图像压缩.考虑来自路径扫描的一维矩阵是:

I try to implement image compression using Burrows-Wheeler transform. Consider an 1D matrix from path scanning is:

p = [2 5 4 2 3 1 5];

,然后应用Burrows-Wheeler变换:

and then apply the Burrows-Wheeler transform :

function output = bwtenc(p) 
n = numel(p);
x = zeros(length(p),1);
for i = 1:length(p)
    left_cyclic = mod(bsxfun(@plus, 1:n, (0:n-1).')-1, n) + 1;
    x = p(left_cyclic);
end
[lex ind] = sortrows(x);
output = lex(:,end);
output = uint8(output(:)');
end

它有效!但是问题是当我尝试从Lena.bmp实现大小为512 * 512的1D矩阵时,错误消息显示bsxfun内存不足.任何人都可以帮助我.

And it works! But the problem is when i try to implement 1D matrix from Lena.bmp which the size is 512*512, Error message showing that bsxfun is out of memory. Anyone please help me.

推荐答案

查看它是否对您有用-

function output = bwtenc(p) 
np = numel(p);
[~,sorted_ind] = sort(p);
ind1 = mod((1:np)+np-2,np)+1;
output = p(ind1(sorted_ind));
output = uint8(output(:)');
end

这篇关于使用bsxfun MATLAB内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆