Find circularity in low signal to noise image with light relfections
Show older comments
Hello,
I would like to find the circularity of the patch in the image.
I know that light reflections should be avoided using polarizers during the image taking process, but I cannot retake these images so I have to analyze what I have.
I have tried the following, which kind of works, however when there are image reflections near the edge of the patch, the circularity (0 to 1) is under captured because it accounts for out of the patch shapes.
Any help or suggestion to improve the code would be appreciated.
Thank you,
I=imread('B1.png');
figure(1)
imshow(I)
title('Original image')
IG=rgb2gray(I);
IG=imadjust(IG);
% Smooth the bright regions by creating a bright mask
thr=prctile(IG(:),80);
brightMask = IG > thr;
windowWidth = 30;
kernel = ones(windowWidth, windowWidth) / windowWidth^2;
blurryIG = imfilter(IG, kernel);
IG(brightMask)=blurryIG(brightMask);
% Binarize and fill gaps
BW=imbinarize(IG);
BW=imfill(BW,'holes');
BW2 = bwareaopen(BW,10000);
BWerode=imerode(BW2,strel('disk',2));
BW3 = bwareaopen(BWerode,10000);
E=edge(BW3);
r=regionprops(BW3,'Circularity')
%% Plot
figure
img=imoverlay(IG,E,'red');
imshow(img)
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing and Computer Vision 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!