@ Tolga, can u pls check the last two lines if correct in creatind the mask to crop out the portion in the circle. Although, the last line is giving error
<??? Attempt to reference field of non-structure array.

Error in ==> max_inscribed_circle at 106
binaryImage =Cin.createMask();>

figure,imshow(BW,[]);
hold on
plot(X,Y,'r','LineWidth',2);
theta = [linspace(0,2*pi) 0];
hold on
AA=cos(theta)*R+cx; BB=sin(theta)*R+cy;
plot(AA,BB,'color','g','LineWidth', 2);

@Tolga , can u be more explicit on creating the mask. Hoe do i use inpoly for dis. Though i tried using the createMask function but realized that d input to match with represent the total circle corodinates, thus not working.
Kindly shed more light
Thanks S M

problem solved . tnks, however i want to ask , is the use of bwtraceboundary only for unit8 images cos i guess that was my problem. After converting my logical im back to unit8, d code ran perfectly.
Also, how do i crop out the content of the circle with a link to d initial binary image or the original image.
Thanks for ur time

Add the following at the bottom of the MidPoint Circle function to created filled circles
for ii = xc-int16(radius):xc+(int16(radius))
for jj = yc-int16(radius):yc+(int16(radius))
tempR = sqrt((double(ii) - double(xc)).^2 + (double(jj) - double(yc)).^2);
if(tempR <= double(int16(radius)))
i(ii,jj)=value;
end
end
end

This code is extremely useful.
I'm not particularly good in using matlab but i had no trouble understanding how to use it (although it took me a good FIVE minutes).
So Five stars for sure for doing EXACTLY what it says on the box, nothing more and nothing less. You guys should be ashamed for rating less then 5 stars.
For others, to get rid of the gaps I used
FilteredResult=medfilt2(Result, [3 3])
This is how I used this code
(you will now notice i'm no good at matlab)
GGG(1:355,1:355)=0;
xxx(1:355,1:355)=0;
y=rand(1,150);
y=y*50
jj=1;
for j=1:150;
AAA=MidpointCircle(xxx,j,177,177,y(1,jj));
GGG=AAA+GGG;
jj=jj+1;
end;
GGG=medfilt2(GGG, [3 3])
image (GGG)

this is a coding to draw a circle.
i using the same code but i looping it with reduce the radius.
let say, my radius is 7, I try looping it by draw radius with 7, and then 6, and then 5 and so on until it become 0. It really fill in a lot of space but the problem is still got some space is empty.
My problem now is I want to fill in all the area inside the circle. So, any idea to solve this problem? Thank you

Comment only