Error in ismemberBi​smemberBui​ltinTypes?

The code below is a region segmentation of an image but I don't know why it give this error?
"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.
Error in ismemberBismemberBuiltinTypes"
I don't understand the error?
function J=regiongrowing(I,x,y,reg_maxdist)
I = im2double(imread('medtest.png'));
x=198; y=359;
J = regiongrowing(I,x,y,0.2);
figure, imshow(I+J);
if(exist('reg_maxdist','var')==0), reg_maxdist=0.2; end
if(exist('y','var')==0)
figure
imshow(I,[]);
[y,x]=getpts;
y=round(y(1));
x=round(x(1));
end
J = zeros(size(I)); % Output
Isizes = size(I); % Dimensions of input image
reg_mean = I(x,y); % The mean of the segmented region
reg_size = 1; % Number of pixels in region
neg_free = 10000; neg_pos=0;
neg_list = zeros(neg_free,3);
pixdist=0;
neigb=[-1 0; 1 0; 0 -1;0 1];
while(pixdist<reg_maxdist&&reg_size<numel(I))
% Add new neighbors pixels
for j=1:4,
% Calculate the neighbour coordinate
xn = x +neigb(j,1); yn = y +neigb(j,2);
% Check if neighbour is inside or outside the image
ins=(xn>=1)&&(yn>=1)&&(xn<=Isizes(1))&&(yn<=Isizes(2));
% Add neighbor if inside and not already part of the segmented area
if(ins&&(J(xn,yn)==0))
neg_pos = neg_pos+1;
neg_list(neg_pos,:) = [xn yn I(xn,yn)]; J(xn,yn)=1;
end
end
% Add a new block of free memory
if(neg_pos+10>neg_free), neg_free=neg_free+10000; neg_list((neg_pos+1):neg_free,:)=0; end
% Add pixel with intensity nearest to the mean of the region, to the region
dist = abs(neg_list(1:neg_pos,3)-reg_mean);
[pixdist, index] = min(dist);
J(x,y)=2; reg_size=reg_size+1;
% Calculate the new mean of the region
reg_mean= (reg_mean*reg_size + neg_list(index,3))/(reg_size+1);
% Save the x and y coordinates of the pixel (for the neighbour add proccess)
x = neg_list(index,1); y = neg_list(index,2);
% Remove the pixel from the neighbour (check) list
neg_list(index,:)=neg_list(neg_pos,:); neg_pos=neg_pos-1;
end
% Return the segmented area as logical matrix
J=J>1;
end

Answers (1)

function J=regiongrowing(I,x,y,reg_maxdist)
okay, so the current function is to be named regiongrowing, and it takes 4 parameters
I = im2double(imread('medtest.png'));
x=198; y=359;
but we are going to ignore whatever was passed for the first three parameters and assign particular values on top of what was passed. Suspicious, but valid
J = regiongrowing(I,x,y,0.2);
Now we are going to call the routine regiongrowing passing in those just-assigned values along with 0.2 as the fourth parameter.
So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2
So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2 So now we look at the code for regiongrowing and find that it is defined as
function J=regiongrowing(I,x,y,reg_maxdist)
so inside the call, I is to be the result of the im2double from the previous call, and x and y are to be the particular values defined in the previous call, and maxdist is to be the 0.2 that we passed in
I = im2double(imread('medtest.png'));
x=198; y=359;
but we ignore those and assign particular values overtop of them,
J = regiongrowing(I,x,y,0.2);
and then we call regiongrowing with those just-assigned values and 0.2
....

1 Comment

I am still laughing. Best use of copy and paste I have seen in a long time.

Sign in to comment.

Asked:

on 25 Mar 2016

Commented:

on 25 Mar 2016

Community Treasure Hunt

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

Start Hunting!