From: Ashish Uthama on 4 May 2010 15:18 > Hi Ashish, > Many many thanks for the help... > > and sorry to ask this again.. > > when ever i use this function the MATLAB is getting crashed.. > > the problem its saying is "Maximum recursion limit of 500 reached. Use > set(0,'RecursionLimit',N) > to change the limit. Be aware that exceeding your available stack space > can > crash MATLAB and/or your computer." > > i increased the recursion limit to 5000 using, > set(0,'recursionlimit',5000)... still the problem remains same.. > > i tried to use the function with a small matrix of size 9x11 ... then > also matlab is getting crashed.. > > whats to be done.. i dont find any significant portion in the code to be > edited... its almost fine.. yeah, I hit that too when I increased the size of the test image. Possibly an algorithm limitation/bug. (btw, I would not call it a 'crash') I would look at the wiki page for flood fill and try replacing the recursive flood fill approach with some of the alternatives listed there.
From: Krishna on 5 May 2010 09:28 "Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.vb66pdkfa5ziv5(a)uthamaa.dhcp.mathworks.com>... > > Hi Ashish, > > Many many thanks for the help... > > > > and sorry to ask this again.. > > > > when ever i use this function the MATLAB is getting crashed.. > > > > the problem its saying is "Maximum recursion limit of 500 reached. Use > > set(0,'RecursionLimit',N) > > to change the limit. Be aware that exceeding your available stack space > > can > > crash MATLAB and/or your computer." > > > > i increased the recursion limit to 5000 using, > > set(0,'recursionlimit',5000)... still the problem remains same.. > > > > i tried to use the function with a small matrix of size 9x11 ... then > > also matlab is getting crashed.. > > > > whats to be done.. i dont find any significant portion in the code to be > > edited... its almost fine.. > > yeah, I hit that too when I increased the size of the test image. > Possibly an algorithm limitation/bug. > > (btw, I would not call it a 'crash') > > > I would look at the wiki page for flood fill and try replacing the > recursive flood fill approach with some of the alternatives listed there. Thanks... i'm also trying for that... I got one more problem with the code.. its giving the result the for first intersection point and for the rest of the points... but not with second intersection point and the rest and so on...
From: Ashish Uthama on 5 May 2010 08:58 On Wed, 05 May 2010 10:28:04 -0300, Krishna <chaitanya.alur(a)gmail.com> wrote: > > i'm also trying for that... I got one more problem with the code.. > > its giving the result the for first intersection point and for the rest > of the points... > > but not with second intersection point and the rest and so on... Works for me: %% generate test image csize=50; cP=4; cQ=7; I=checkerboard(csize,cP,cQ); %400x700 for above params I=edge(I,'canny'); I=imclose(I,strel('disk',csize/5)); %seperate into two regions I(cP*csize:cP*csize+1,:)=0; %junction points jPoints = [ 48 150 197 149 252 498 251 251 ]; %% show test data figure; imshow(I);hold on; plot(jPoints(:,2),jPoints(:,1),'r*'); >> clear all >> set(0,'RecursionLimit',4000) >> tic >> junConMat = findNeighborJunction(I,jPoints) junConMat = 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 >> toc Elapsed time is 3.996977 seconds.
From: Krishna on 5 May 2010 13:02 "Ashish Uthama" <first.last(a)mathworks.com> wrote in message <op.vb8jq9ffa5ziv5(a)uthamaa.dhcp.mathworks.com>... > On Wed, 05 May 2010 10:28:04 -0300, Krishna <chaitanya.alur(a)gmail.com> > wrote: > > > > > i'm also trying for that... I got one more problem with the code.. > > > > its giving the result the for first intersection point and for the rest > > of the points... > > > > but not with second intersection point and the rest and so on... > > > Works for me: > > %% generate test image > csize=50; > cP=4; > cQ=7; > I=checkerboard(csize,cP,cQ); %400x700 for above params > I=edge(I,'canny'); > I=imclose(I,strel('disk',csize/5)); > > %seperate into two regions > I(cP*csize:cP*csize+1,:)=0; > > %junction points > jPoints = [ > 48 150 > 197 149 > 252 498 > 251 251 > ]; > > > %% show test data > figure; imshow(I);hold on; plot(jPoints(:,2),jPoints(:,1),'r*'); > > > > > > > >> clear all > >> set(0,'RecursionLimit',4000) > >> tic > >> junConMat = findNeighborJunction(I,jPoints) > > junConMat = > > 0 1 0 0 > 0 0 0 0 > 0 0 0 1 > 0 0 0 0 > > >> toc > Elapsed time is 3.996977 seconds. %------------------------------------------------------------- Yeah you are right.. But, can you check with this matrix once... T = [ 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 0 ; 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0; 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 1; 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1; 0 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0; 0 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0; 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0; 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0; 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0; 0 1 1 0 1 0 0 1 0 0 0 1 0 1 0 0; 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 0; 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0; 1 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0;]; %Junction points jun = [5,2; 2,4; 8,4; 7,9; 1,8; 5,6; 2,10; 9,9; 11,7; 11,11]; %connected junction matrix CJ = findConnectedJunctions(T,jun) the out put is as follows, CJ = 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 there are couple of intersection points in between first and ninth points in 'jun' matrix..but still its showing a connection between first and nine...which i think an error..you please have a look at it... again as you said its showing recursion error when the size of the matrix is increased.. kindly help me for this.. many many thanks...
From: Ashish Uthama on 5 May 2010 15:36 On Wed, 05 May 2010 13:02:05 -0400, Krishna <chaitanya.alur(a)gmail.com> wrote: > %------------------------------------------------------------- > > Yeah you are right.. > > But, can you check with this matrix once... > > T = [ 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 0 ; > 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0; > 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 1; > 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1; > 0 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0; > 0 0 1 0 1 0 1 1 1 0 0 0 0 1 0 0; > 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0; > 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0; > 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0; > 0 1 1 0 1 0 0 1 0 0 0 1 0 1 0 0; > 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 0; > 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0; > 1 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0;]; > > %Junction points > jun = [5,2; 2,4; 8,4; 7,9; 1,8; 5,6; 2,10; 9,9; 11,7; 11,11]; > > %connected junction matrix > CJ = findConnectedJunctions(T,jun) > > the out put is as follows, > > CJ = > > 0 1 1 1 0 1 0 1 1 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 1 0 1 > 0 0 0 0 0 1 1 0 0 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 > 0 0 0 0 0 0 0 0 0 0 Nope, The code I posted gives CJ = 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Visual inspection verifies this as the expected answer. > there are couple of intersection points in between first and ninth > points in 'jun' matrix..but still its showing a connection between first > and nine...which i think an error..you please have a look at it... I believe you have modified the code. You would have to single step and debug your changes. > again as you said its showing recursion error when the size of the > matrix is increased.. kindly help me for this.. I did. In my previous post, where I suggested using an iterative approach (clearly outlined in the wiki page link). Or, if your machine can handle it.. keep increasing the recursion limit. I would strongly recommend rewriting the flood fill algo using a iterative approach. Another thought I was toying with is to use IMFILL: I = image with 1 marking foreground, 1 marking background nI = ~I; %IMPORTANT! IMFILL works on the 'background', we want to work on 1 so invert. for (src = all junction points) for(dst = all junction points) copy_nI=I; copy_nI=imfill(copy_nI,src); %Look at help/doc for connectivity parameters if(copy_nI(dst) == 1) src and dst are connected else they are not end end end Downside- multiple copies being worked on, this might be offset by the toolbox implementation of IMFILL being better optimized.
First
|
Prev
|
Pages: 1 2 3 4 5 Prev: how to create a custom bit pattern in simulink Next: find centroid of a moving object |