Hi, I'm having trouble with the segmentation of fish eye
I follow the instruction from this: https://www.mathworks.com/help/images/detecting-a-cell-using-image-segmentation.html?fbclid=IwAR3MPi9mlL6Rt8R7sA20oyZdvoiMhIpxpW-dxjSUfmoNcX-g9u2_5cn6V3Y
I changed some parameters and successfully segmented the fish eye like the image I attached.
However, for the fish that is stale like the image attached, the code couldn't segment the eye.
Can anyone help me to solve the problem ? And how can I segment the fish eye successfully in any situation (Fresh and stale fishes) ?
Thanks in advance.
Here is my code:
I = imread('');I = imresize(I,[500 500]);I = rgb2gray(I);[~,threshold] = edge(I,'sobel');fudgeFactor = 1;BWs = edge(I,'sobel',threshold * fudgeFactor);figureimshow(BWs)title('Binary Gradient Mask')se90 = strel('line',1,90);se0 = strel('line',1,0);BWsdil = imdilate(BWs,[se90 se0]);figureimshow(BWsdil)title('Dilated Gradient Mask')BWdfill = imfill(BWsdil,'holes');figureimshow(BWdfill)title('Binary Image with Filled Holes')BWnobord = imclearborder(BWdfill,4);figureimshow(BWnobord)title('Cleared Border Image')seD = strel('diamond',1);BWfinal = imerode(BWnobord,seD);BWfinal = imerode(BWfinal,seD);figureimshow(BWfinal)title('Segmented Image');BWmask = labeloverlay(I,BWfinal);figureimshow(BWmask)title('Mask Over Original Image')BWoutline = bwperim(BWfinal);Segout = I; Segout(BWoutline) = 255; figureimshow(Segout)title('Outlined Original Image')maskedGrayImage = bsxfun(@times, I, cast(BWfinal, 'like', I));figureimshow(maskedGrayImage)
Best Answer