From: saurabh pandey on
hello friends,i am working in "segmentation using morphology".i am new in matlab.i make a code using matlab help,but this code is not working perfectly.actually i am segmenting "cells".also it is not working on another image.
images are uploaded to picasa web in album" saurabh_work_matlab"http://picasaweb.google.com/lh/view?q=saurabh_work_matlab&psc=G&filter=1#

my code is

close all
I = imread('1.jpg');
imshow(I)
[junk threshold]=edge(I,'sobel');
fudgeFactor = 0.6;
f=edge(I,'sobel',threshold*fudgeFactor);
figure,imshow(f)
se90=strel('line',5,90);
se0=strel('line',5,0);
d=imdilate(f,[se90 se0]);
figure,imshow(d)
s=strel('octagon',9);
f0=imopen(d,s);
figure,imshow(f0)
fl=imfill(f0,'holes');
figure,imshow(fl)
t=bwmorph(fl,'thin',1);
t1=bwmorph(fl,'thin',2);
imshow(t),figure,imshow(t1)
bor=imclearborder(t1,26);
figure,imshow(bor)
sed=strel('disk',6);
borfinal=imerode(bor,sed);
figure,imshow(borfinal)
sed1=strel('disk',25);
f2=imopen(borfinal,sed1);
figure,imshow(f2);
whos
f3=im2uint8(f2);
figure,imshow(f3);
sed2=strel('disk',20);
f4=imopen(f3,sed2);
figure,imshow(f4);
sed3=strel('line',4,90);
f5=imopen(f4,sed3);
figure,imshow(f5);
whos
[gv,t]=edge(f5,'sobel','horizontal');
figure,imshow(gv);
kk = bwperim(f5);
figure,imshow(kk)
segout=I;
segout(kk)=255;
figure,imshow(segout)

this code is not working on another image also..plzz help meeeeeeeeeeee......
i will be thankful of you..plzz reply to sathiya.saurabh(a)gmail.com