You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Out of memory. The likely cause is an infinite recursion within the program. Error in resample1 (line 6) y = resample1(x, type, shift, extmod);
1 view (last 30 days)
Show older comments
%
img = double(imread('barbara.jpg','jpg'));
%end
[row col] = size(img);
ndir = [2 2 1 1 0];
for j = 1:5
for k = -2^(ndir(j)):2^(ndir(j))
coeff_h{j}(:,:,k+(2^(ndir(j))+1)) = obtain_shear_coeff(img,[3 3 4 4 5],ndir(j),'hor',j,k);
%Keep only the highest magnitude
ind=coeff_h{j}(:,:,k+(2^(ndir(j))+1))<0;
coeff_h{j}(:,:,ind)=0;
coeff_v{j}(:,:,k+(2^(ndir(j))+1)) = obtain_shear_coeff(img,[3 3 4 4 5],ndir(j),'ver',j,k);
end
end
% Display original image
colormap gray;
subplot(1,1,1), imagesc( img, [0 255] ) ;
title( sprintf('Original Image' )) ;
% Display shearlet coeff for horizontal cone
figure; clf;
colormap gray;
tmp1 = []; tmp2 = []; tmp3 = []; tmp4 = []; tmp5 = [];
for k = 1:9
if k < 9
tmp1 = [ tmp1; coeff_h{1}(:,:,k); 255*ones(5,col/2) ];
else
tmp1 = [ tmp1; coeff_h{1}(:,:,k)];
end
end
for k = 1:9
if k < 9
tmp2 = [ tmp2; coeff_h{2}(:,:,k); 255*ones(5,col/4) ];
else
tmp2 = [ tmp2; coeff_h{2}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp3 = [ tmp3; coeff_h{3}(:,:,k); 255*ones(5,col/8) ];
else
tmp3 = [ tmp3; coeff_h{3}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp4 = [ tmp4; coeff_h{4}(:,:,k); 255*ones(5,col/16) ];
else
tmp4 = [ tmp4; coeff_h{4}(:,:,k)];
end
end
for k = 1:3
if k < 3
tmp5 = [ tmp5; coeff_h{5}(:,:,k); 255*ones(5,col/32) ];
else
tmp5 = [ tmp5; coeff_h{5}(:,:,k)];
end
end
subplot(1,5,1), imagesc( tmp1 ) ;
subplot(1,5,2), imagesc( tmp2 ) ;
subplot(1,5,3), imagesc( tmp3 ) ;
title( sprintf('Shearlet Coefficients for horizontal cone' )) ;
subplot(1,5,4), imagesc( tmp4 ) ;
subplot(1,5,5), imagesc( tmp5 ) ;
% Display shearlet coeff for vertical cone
figure; clf;
colormap gray;
tmp1 = []; tmp2 = []; tmp3 = []; tmp4 = []; tmp5 = [];
for k = 1:9
if k < 9
tmp1 = [ tmp1 coeff_v{1}(:,:,k) 255*ones(row/2,5) ];
else
tmp1 = [ tmp1 coeff_v{1}(:,:,k)];
end
end
for k = 1:9
if k < 9
tmp2 = [ tmp2 coeff_v{2}(:,:,k) 255*ones(row/4,5) ];
else
tmp2 = [ tmp2 coeff_v{2}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp3 = [ tmp3 coeff_v{3}(:,:,k) 255*ones(row/8,5) ];
else
tmp3 = [ tmp3 coeff_v{3}(:,:,k)];
end
end
for k = 1:5
if k < 5
tmp4 = [ tmp4 coeff_v{4}(:,:,k) 255*ones(row/16,5) ];
else
tmp4 = [ tmp4 coeff_v{4}(:,:,k)];
end
end
for k = 1:3
if k < 3
tmp5 = [ tmp5 coeff_v{5}(:,:,k) 255*ones(row/32,5) ];
else
tmp5 = [ tmp5 coeff_v{5}(:,:,k)];
end
end
subplot(5,1,1), imagesc( tmp1 ) ;
title( sprintf('Shearlet Coefficients for vertical cone' )) ;
subplot(5,1,2), imagesc( tmp2 ) ;
subplot(5,1,3), imagesc( tmp3 ) ;
subplot(5,1,4), imagesc( tmp4 ) ;
subplot(5,1,5), imagesc( tmp5 ) ;
8 Comments
Steven Lord
on 24 Oct 2021
Nowhere in this code does a call to resample1 appear. Nor is resample1 a function in MATLAB.
which -all resample1
'resample1' not found.
Show us the definition of the resample1 function. Based on the error message it calls itself and because you're receiving an error if it is intended to be recursive it's missing the base case condition (that returns an answer without making a recursive call.)
Image Analyst
on 24 Oct 2021
In addition to what Steve said above (click Show comments), attach barbara.jpg, obtain_shear_coeff.m, and resample1.m so we can run your code.
Your m-file is not called resample1.m and you're calling resample1.m inside of it are you?
linou landini
on 24 Oct 2021
% This routine is copied from Contourlet Toolbox.
function y = resample1(x, type, shift, extmod)
y = resample1(x, type, shift, extmod);
% Resampling according to shear matrix [1 s ; 0 1]
% See source code resample1.c
Image Analyst
on 24 Oct 2021
@linou landini okay . . . you're partially helping us help you but not completely.
- What happened when you did what Steve said?
- And you didn't attach the ''barbara.jpg' I asked for.
- Finally, the Contourlet Toolbox is not a Mathworks product. We don't have it and you didn't give a link to it. Maybe since it's some third party function you should ask that third party.
Help us to help you. Right now we can't.
Answers (1)
Steven Lord
on 24 Oct 2021
I'm not familiar with this third-party Contourlet Toolbox (you may need to talk to the author of that toolbox for help) but this comment in resample1.m (which is NOT going to work as written) makes me wonder if resample1.m was a "backup" for a MEX-file and was never intended to be executed.
% See source code resample1.c
Did the installation instructions for this toolbox instruct you to run a command to build MEX-files?
40 Comments
linou landini
on 24 Oct 2021
@Steven Lord No , just I run this code that I transmitted to you , but the error is displayed : Out of memory. The likely cause is an infinite recursion within the program.
Walter Roberson
on 24 Oct 2021
Which version of ShearLab did you install? Where did you get it from?
linou landini
on 24 Oct 2021
@Walter Roberson version 1.10 . I didn't install, but just put the code and ran shearlab 1.1 .m. here is execution:

Walter Roberson
on 24 Oct 2021
ShearLab-1.1 arrives with .mexw32 files, suitable only for use with MATLAB 32 bit R2015b or earlier.
You need to use mex to build each of the .mex files for your system.
Look in the directories for .mexw32 files. You will need to generate code for each of them. For example, possibly
mex reshape1.c
linou landini
on 24 Oct 2021
Edited: linou landini
on 24 Oct 2021
@Walter Roberson I found files called mdwt.mexw32
But how do i perform this step "You will need to generate code for each of them" ?
Image Analyst
on 24 Oct 2021
The "mex" command will regenerate the mex file, if it's not already included in your installation package from the third party Toolbox publisher.
Sorry, but many of us don't want to go to the trouble of downloading (and possibly buying) some third party toolbox just to help you. Maybe the publisher has a support forum, or you can call them.
Walter Roberson
on 25 Oct 2021
http://shearlab.math.lmu.de/software#shearlab11 has download links for 64 bit MATLAB
linou landini
on 25 Oct 2021
Edited: linou landini
on 25 Oct 2021
@Image Analyst @Walter Roberson Yes I download the shearlab11 but when I run the shearlab this error is displayed.
Error using mex
Access denied; check that you have permissions to access 'C:\Program
Files\MATLAB\R2016a\toolbox\ShearLab-1.1\MEX'.
and it's the same when i run in my office C:\Users\TOSHIBA\Desktop\ShearLab-1.1
linou landini
on 25 Oct 2021
Edited: linou landini
on 25 Oct 2021
@Steven Lord @Walter Roberson I followed their steps https://www.youtube.com/watch?v=12XRTUqG94Y but the same error

Steven Lord
on 25 Oct 2021
As that message suggests, please consult your system administrator (someone in your IT department) for help in determining why you don't have permissions to access the file in your installation.
linou landini
on 25 Oct 2021
@Steven Lord can i work Mex in window 64? yet I installed it using video youtube
Walter Roberson
on 25 Oct 2021
You should never install a third-party software package under the MATLAB installation directory.
Also, you will need to install a third-party compiler. The ones that will work on your R2016a are listed at https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/SystemRequirements-Release2016a_SupportedCompilers.pdf
Note that all of the Visual Studio versions that it lists are "Professional" editions. In your release, the "Express" and "Community" editions will not work.
Walter Roberson
on 26 Oct 2021
You cannot upgrade mexw32 to mexw64. If you have source code you can recompile.
However, I do not understand why you would do that. I posted a link earlier to the place that has windows 64 executables.
linou landini
on 26 Oct 2021
Edited: linou landini
on 26 Oct 2021
@Walter RobersonI did not find any link that runs the code in 64bit, can you give me plz
I downloaded shearlab1.1(64 bit window) in the site http://shearlab.math.lmu.de/software but the same error
Walter Roberson
on 26 Oct 2021
I repeat, "You should never install a third-party software package under the MATLAB installation directory."
The Shearlab files should not be placed under C:\Program Files . Put them in one of your own directories.
Walter Roberson
on 26 Oct 2021
Please show the current error message.
I have no idea about inverse shearlet.
linou landini
on 27 Oct 2021
@Walter Roberson hi, when I run the shearlab file '' Pathnames Successfully Set "but when i tested the code the same error

Walter Roberson
on 27 Oct 2021
Please show the output of
which -all resample1
which -all demo_shear_coeff
demoloc = which('demo_shear_coeff');
demodir = fileparts(demoloc);
ls( fullfile(demodir, '*.mex*') )
linou landini
on 27 Oct 2021
@Walter Roberson I put the MinGW folder on the folder in C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
Walter Roberson
on 27 Oct 2021
I had a closer look at the installation files.
Sorry, but ShearLabs-1.1 is not suitable for installation on Windows Vista or later.
It is also not suitable for installation on any Intel or ARM based Mac -- only for the PowerPC Mac running OS 9.
It might be possible to adapt the installation files to work on later versions, but the installation files that come with it are old
Walter Roberson
on 28 Oct 2021
The solution is for someone to take the time to write new installation code and new installation instructions.
Walter Roberson
on 29 Oct 2021
Someone would have to redesign the installation code. The installation instructions would depend upon how they decided to redesign it.
Steven Lord
on 29 Oct 2021
At this point, I think probably you'd be better served contacting the author and/or maintainer of ShearLab and asking for help getting it installed and working on your system. Then that person or group of people may want to revise their installation code and/or instructions.
Walter Roberson
on 9 Nov 2021
linou landini
on 9 Nov 2021
@Walter Roberson thank you but the email address is not functional of maintainer of shearlab!
Walter Roberson
on 9 Nov 2021
linou landini
on 10 Nov 2021
@Walter Roberson it's the same thing, the email of each personal is not functional!
Melika Azmoun
on 27 May 2022
hi, linou landini.
Was the problem solved?
Can you guide me too?
Because I also have the same problem.
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)