I get an error, could you guys help me to figure out?

조회 수: 15 (최근 30일)
Zhen Weng
Zhen Weng 2014년 9월 1일
댓글: Walter Roberson 2018년 3월 19일
Error using bsxfun Out of memory. Type HELP MEMORY for your options.
Error in classreg.learning.internal.wnanmean (line 12) X = bsxfun(@times,X,W);
Error in pca (line 284) mu = classreg.learning.internal.wnanmean(x, vWeights);
Error in princomp (line 29) [varargout{1:nargout}]=pca(varargin{1},'Algorithm','svd','Economy',fEconomy);
Error in pca_for_Zhen (line 36) [coeff, score, latent]=princomp(data,'econ');
[fname pname]=uigetfile('*.*','Please click any image in your folder');
cd(pname);
filenamelist=dir(pwd);
nel=length(filenamelist);
index=0;
sampleImage=im2double(imread(fname));
vsampleImage=sampleImage(:);
[numRows numCols]=size(sampleImage);
data=zeros(size(vsampleImage,1),200);
label='Zhen sample';
for i=3:1:102
% here you are try from 3 (the first image with signal) to any arbitrary
% number and find out how many frames you need in your case. This number
% is different since the exposure time and frame rate is different from
% our setup to your imaging setup.
if filenamelist(i).isdir~=1
if mod(i,1)==0
index=index+1
fname=filenamelist(i).name;
tempData=im2double(imread(fname));
data(:,index)=tempData(:);
end
end
end
[coeff, score, latent]=princomp(data,'econ');
n=score>=0;
posscore=n.*score;
m=score<=0;
negscore=m.*score;
figure
for j=1:9
subplot(3,3,j)
pcolor(reshape(score(:,j),numRows,numCols));axis image;shading flat;axis ij;
text(5,20,[label ' ' sprintf('%d',j)],'Color','w','FontWeight','bold')
axis off;
colormap jet;
end
cd('..');
%print(gcf,'-dpdf',[label ' components.pdf']);
%rgb overlay
impos=zeros(numRows,numCols);
%positive
impos(:,:,1)=reshape(posscore(:,2),numRows,numCols);
impos(:,:,2)=reshape(posscore(:,3),numRows,numCols);
impos(:,:,3)=reshape(posscore(:,4),numRows,numCols);
for k=1:3
impos(:,:,k)=impos(:,:,k)/max(max(impos(:,:,k)));
end
figure
image(impos);
axis image;
title([label ' Positive']);
%print(gcf,'-dpdf',[label ' positive.pdf']);
%negative
imneg=zeros(numRows,numCols);
imneg(:,:,1)=reshape(-negscore(:,2),numRows,numCols);
imneg(:,:,2)=reshape(-negscore(:,3),numRows,numCols);
imneg(:,:,3)=reshape(-negscore(:,4),numRows,numCols);
for k=1:3
imneg(:,:,k)=imneg(:,:,k)/max(max(imneg(:,:,k)));
end
figure
image(imneg);
axis image;
title([label ' Negative']);
%print(gcf,'-dpdf',[label ' negative.pdf']);
imoverlay=zeros(numRows,numCols); for k=1:3
imoverlay(:,:,k)=impos(:,:,k)+imneg(:,:,k);
imoverlay(:,:,k)=imoverlay(:,:,k)/max(max(imoverlay(:,:,k)));
end
figure
image(imoverlay);
axis image;
title([label ' Overlay']);
  댓글 수: 3
Guillaume
Guillaume 2014년 9월 1일
편집: Guillaume 2014년 9월 1일
The error has nothing to do with Java or the Java heap memory. Increasing the heap memory won't help solve the error. If anything it will make it even more likely as it'll reduce the memory available for matlab arrays.
Zhen, I would put a breakpoint on the line with the call to princomp and when the breakpoint is hit, look at what memory and whos tell you.
Stephen23
Stephen23 2014년 9월 1일
편집: Stephen23 2014년 9월 1일
Zhen Weng: please do not post the same question multiple times.
Your last post of this question generated two comments giving advice that you should format your code to be more readable, and also to give some details of what you understand of the problem. This advice is aimed to make it easier for people to help you: spamming the same question multiple times will discourage people from helping you. Please simply edit your original question, or add comments to clarify details.

댓글을 달려면 로그인하십시오.

답변 (2개)

Iain
Iain 2014년 9월 1일
The error is that something is using too much memory. If your images are huge, this is a possible result.
You have a few ways of dealing with it:
1. Increase the amount of RAM you have on the system you're using.
2. Reduce the amount of stuff you're running to increase usable RAM (e.g. outlook, word, excel, etc.)
3. Reduce the amount of RAM you need. - Try with 2 files, rather than 101.

xing peng
xing peng 2018년 3월 19일
편집: Walter Roberson 2018년 3월 19일
for the question of:
Error in princomp (line 29) [varargout{1:nargout}]=pca(varargin{1},'Algorithm','svd','Economy',fEconomy);
please try set path as the default.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by