i have been segmented some image of retina. but the result is not good as i hope. for one image i can get good segmentation, like this image
my code is from some reference in internet, in below i will write my code and this code is start when i have got a filtered image (mean filtering) .
prewitthor = [-1 0 1; -1 0 1; -1 0 1]; prewittver = [-1 -1 -1; 0 0 0; 1 1 1]; Ix = imfilter(double(imgMeanfilter),prewitthor,'replicate'); Iy = imfilter(double(imgMeanfilter),prewittver,'replicate'); J = sqrt((Ix.^2)+(Iy.^2)); g = J - min(J(:)); g = g / max(g(:)); th = graythresh(g); %# Otsu's method. a = imhmax(g,th/2); %# Conservatively remove local maxima. th = graythresh(a); b = a > th/4; %# Conservative global threshold. c = imclose(b,ones(3)); %# Try to close contours. d = imfill(c,'holes'); %# Not a bad segmentation by itself. %# Use the rough segmentation to define markers. % g2 = imimposemin(g, ~ imdilate( bwperim(a), ones(3) )); L = watershed(c); boundaries = L == 0; redChanel(boundaries) = 255;