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');
Text is just single layer fill so I do it in C++ like this:
Here are how the stages looks like:
Algorithm is like this:
co
(some unused color)co
co
ci
(some unused color)ci
merge / recolor source and result images
copy edges from source image and inside from result image the rest is space
I use my own picture class for images so some members are:
xs,ys
size of image in pixelsp[y][x].dd
is pixel at (x,y) position as 32 bit integer typeclear(color)
- clears entire imageresize(xs,ys)
- resizes image to new resolutionIf you have special characters that have more layers
then just add more stages ...
layer
is how many layers of space there can be from most inner space/hole to the outer space also you can loop until no more layer found ...let use this code it will use for you . thanks to @ spektre .
You can do this with a few other clever calls to
imfill
. Here is a way, assuming your binary image is in the arrayBW
:and
Res
is a binary image that contains the desired output: