Automatically segment the fish eye
Show older comments
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);
figure
imshow(BWs)
title('Binary Gradient Mask')
se90 = strel('line',1,90);
se0 = strel('line',1,0);
BWsdil = imdilate(BWs,[se90 se0]);
figure
imshow(BWsdil)
title('Dilated Gradient Mask')
BWdfill = imfill(BWsdil,'holes');
figure
imshow(BWdfill)
title('Binary Image with Filled Holes')
BWnobord = imclearborder(BWdfill,4);
figure
imshow(BWnobord)
title('Cleared Border Image')
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure
imshow(BWfinal)
title('Segmented Image');
BWmask = labeloverlay(I,BWfinal);
figure
imshow(BWmask)
title('Mask Over Original Image')
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
figure
imshow(Segout)
title('Outlined Original Image')
maskedGrayImage = bsxfun(@times, I, cast(BWfinal, 'like', I));
figure
imshow(maskedGrayImage)
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

