How do I remove the Specular reflections in gray scale image as given in this article snippet?

2 views (last 30 days)
Kindly help.
  2 Comments
DGM
DGM on 4 Feb 2024
Edited: DGM on 4 Feb 2024
It's not clear how one can identify specular reflections simply as being a bright regions which are not connected to the image boundary. Unless these images are cropped such that the sclera always is connected to the image boundary and the specular reflections are not connected to the sclera, it's easy to conceive an image which would defeat this process. It's also not really clear why inverting the image is even necessary. Something like imregionalmax() might be useful, as a specular highlight should be a large connected maximal region. I'd have to see characteristic images to know what's plausible.

Sign in to comment.

Answers (1)

DGM
DGM on 4 Feb 2024
Well forget about trying to use imregionalmax() on that. It looks like a captured frame of interlaced video that's been saved as a 4:2:0 JPG, so there's no such thing as a clean edge or a uniform region left anywhere in the image.
The problem is that all the specular highlights are not flat, and they're not even anyhere near white anymore. They're filled with artifacts that are influenced by their surroundings. This is compounded by the fact that the source is likely video, so the highlights are surrounded by severe undershoot, making the polluting artifacts even darker than they would otherwise be. This also means that in order to perform inpainting, the mask doesn't just need to span the highlight. It also needs to span all the undershoot and ringing artifacts that surround it.
We could just use a very generous thresholding operation to maybe get the highlights, but trying to capture the surrounding artifacts or penumbra will mean we're just liberally dilating things, so boundary connectivity is probably not a helpful means of discrimination anymore.
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1607926/image.jpeg');
inpict = im2gray(inpict);
mk = inpict > 180; % a generous thresholding operation
mk = imdilate(mk,strel('disk',5)); % dilate at least enough to get the dark undershoot
outpict = regionfill(inpict,mk); % inpaint
imshow(outpict,'border','tight')
Even after masking and dilation, the penumbra around the large reflection in the corner is still enough to make the inpainting light gray. Attempting to dilate further will only degrade the pupil details.
Bear in mind that trying to process this inpainted image with edge detection is going to be a mess. The inpainting will soften the pupil edge, and the interlacing and JPG artifacts will scatter the edge in any regions untouched by the inpainting.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!