Hi ZMY,
It is my understanding that you have obtained a segmented mask of the ROI in your image using watershed algorithm and you want a workaround to overlay the mask on the actual image to extract the optic disk.
Follow the below steps for extracting the optic disc after applying the watershed transform:
- Obtain a binary mask for the orange region in the image using RGB or HSV-based colour segmentation techniques. Leverage the “MATLAB Color Thresholder App” to ease up this work.
- To overlay this 2D mask to 3D image do the following:
- Invert the mask and replicate it thrice along the channel dimension.
- Set the rest of the area in the image other the ROI as 0.
Refer to the following code snippet to obtain the segmented optic disc:
wsimg=imread("watershed.png");
wsimg=imresize(wsimg,[w,h]);
img(repmat(~mask,[1 1 3])) = 0;
function [BW,maskedRGBImage] = createMask(RGB)
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
Results
1.Original Image
2.Resized Watershed Image
3.Binary mask of ROI
4.Overlayed mask on image
As a suggestion, since the optic disc spot is bright, you could have achieved the same result relatively easier using the HSV thresholding.
Hope this helps in extracting the optic disc after applying the watershed transform .
Regards,
Vinayak Luha