How to fill the unclosed shape?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kei Mukoyama
el 12 de Dic. de 2022
Comentada: Image Analyst
el 13 de Dic. de 2022
I am now trying to create a mask to use in a machine learning annotation file.
In doing so, I would like to binarize the droplet image with a threshold value and then fill the inside of the droplet with imfill.
However, sometimes the boundary becomes an open curve due to some thinness in the boundary area.
In this case, what can I do to fill this area automatically?
Here is the code.
This is the first time to ask a question on matlab and I am not a fluent in English, so I apologize if there is any rudeness.
I_pp=double(rgb2gray(imread("img0.jpg")));
%I_bg=double(rgb2gray(imread("bg.jpg")));
diff=I_pp; %-I_bg;
min(min(diff))
result=((diff-min(min(diff)))/(max(max(diff))-min(min(diff))));
imshow(result)
level=graythresh(result);
BW=imbinarize(result,level);
BW(1:7, :)=1;
BW(end-7:end,:)=1;
BW= 1-BW;
BW2 = bwmorph(BW, 'bridge');
BW2=imclose(BW2,strel('disk',2));
imshow(BW2)
%%
I2 = imfill(BW2,'holes');
imshow(I2)
0 comentarios
Respuesta aceptada
Image Analyst
el 12 de Dic. de 2022
You can try imclose, but that's not your biggest problem. Your biggest problem is the non-uniformity of your illumination. It's most likely due to lens shading. You need to divide that out. First take a "blank" shot of nothing -- just the light background itself. Then divide your images with stuff in them by the background image. I attach a demo.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!