I have a number plate which is a binary image.

I performed dilation to the image to thicken the edges then "flood filling", lastly erosion for thinning:

But i want my output to be like this:

Can anyone help me, please? And show me how to get the desired output.
ab=imread('test1.png');
level=graythresh(ab);
ab=im2bw(ab,level);
se=strel('disk',1);
ab=imdilate(ab,se);
ab=imfill(ab,'holes');
ab=bwmorph(ab,'thin',1);
ab=imerode(ab,strel('line',3,90));
figure();imshow(ab,[]); title('floodFilling');
You can do this with a few other clever calls to imfill. Here is a way, assuming your binary image is in the array BW:
Tmp = imfill(BW, 'holes');
Tmp2 = imfill(Tmp-BW, 'holes');
Res = Tmp - imfill(BW & Tmp2, 'holes');
and Res is a binary image that contains the desired output:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With