hi im getting error like out of memory, likely cause in infinite recursion within the program can anyone help me out plz.. Thank you in advance
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function bloodVessels = VesselExtract(inImg, threshold)
%Read Input Retina Image inImg = imread('lfretina.jpg'); dim = ndims(inImg); if(dim == 3) %Input is a color image inImg = rgb2gray(inImg); end
%Extract Blood Vessels Threshold = 10; bloodVessels = VesselExtract(inImg, Threshold);
%Output Blood Vessels image
figure; subplot(121);imshow(inImg);title('Input Image'); subplot(122);imshow(bloodVessels);title('Extracted Blood Vessels');
%Kirsch's Templates h1=[5 -3 -3; 5 0 -3; 5 -3 -3]/15; h2=[-3 -3 5; -3 0 5; -3 -3 5]/15; h3=[-3 -3 -3; 5 0 -3; 5 5 -3]/15; h4=[-3 5 5; -3 0 5; -3 -3 -3]/15; h5=[-3 -3 -3; -3 0 -3; 5 5 5]/15; h6=[ 5 5 5; -3 0 -3; -3 -3 -3]/15; h7=[-3 -3 -3; -3 0 5; -3 5 5]/15; h8=[ 5 5 -3; 5 0 -3; -3 -3 -3]/15;
%Spatial Filtering by Kirsch's Templates t1=filter2(h1,inImg); t2=filter2(h2,inImg); t3=filter2(h3,inImg); t4=filter2(h4,inImg); t5=filter2(h5,inImg); t6=filter2(h6,inImg); t7=filter2(h7,inImg); t8=filter2(h8,inImg);
s=size(inImg); bloodVessels=zeros(s(1),s(2)); temp=zeros(1,8);
%
for i=1:s(1) for j=1:s(2) temp(1)=t1(i,j);temp(2)=t2(i,j);temp(3)=t3(i,j);temp(4)=t4(i,j); temp(5)=t5(i,j);temp(6)=t6(i,j);temp(7)=t7(i,j);temp(8)=t8(i,j); if(max(temp)>threshold) bloodVessels(i,j)=max(temp); end end end
0 Kommentare
Antworten (1)
Roger Stafford
am 14 Nov. 2017
Yes, your guess is correct. There is no way a call on ‘VesselExtract’ can avoid doing an infinitely deep recursion as your code stands at present. You need to rethink the portion after “%Extract Blood Vessels”. There has to be some criterion that can make sure you don’t keep redoing this call to “extract blood vessels” indefinitely many times. You need a way to “get out of the loop”, so to speak.
Just as an example, suppose you only want to call it n levels deep. Then add a count to your input arguments that starts out at n and gets reduced by one each time you call it recursively. Then provide for a means of exiting when the count gets down to zero.
I doubt that it’s that simple, but I think you are the only one who understands what you have in mind by doing this recursion. Just think what it is that should cause the recursion to stop, and then revise your code to accomplish that.
Recursion is a very powerful tool, but, as your code demonstrates, it can easily be abused.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Biomedical Imaging finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!